Legion of Learners
www.lol-101.com
Home
Classrooms
Courses
About Us
Executive Team
Board Members
Resources
More
Use tab to navigate through the menu items.
Log In
Forum Comments
Methods Homework 4/25/2020
In Java Question Bank
mathnerd1003
May 02, 2020
Justin Ely
0
Methods Homework 4/25/2020
In Java Question Bank
mathnerd1003
May 02, 2020
import java.util.*; import java.io.*; class Main { public static void main(String[] args) { String str = ""; Scanner in = new Scanner(System.in); System.out.println("Enter a string"); String s = in.nextLine(); Scanner t = new Scanner(System.in); System.out.println("Enter an increment"); int c = t.nextInt(); int len = s.length(); for(int i = 0; i<len; i++){ char q = s.charAt(i); char w = (char)(q+c); if (q>='a' && q<='z'){ if (w>'z') { w = (char)('a' + w - 'z' - 1); } } if (q>='A' && q<='Z') { if (w>'Z') { w = (char)('A' + w - 'Z' - 1); } } str = str + w; } System.out.println(str); } }
0
1
m
mathnerd1003
0
Followers
0
Following
Follow
Following icon
More actions
Profile
Forum Comments
Forum Posts
More
Use tab to navigate through the menu items.