Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. package feb21;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class t1 {
  6. public static void main(String args[]) {
  7. Scanner in = new Scanner (System.in);
  8. System.out.println("Enter a starting and ending spot in the alphabet (1-26):");
  9. int num1, num2;
  10. num1 = in.nextInt();
  11. num2 = in.nextInt();
  12. while((num1 < 1 || num1 > 52) || (num2 < 1 || num2 > 52)) {
  13. System.out.println("Invalid Entry. Try Again.");
  14. num1 = in.nextInt();
  15. num2 = in.nextInt();}
  16. System.out.println(printABC(num1,num2));
  17. }
  18. public static String printABC(int num1, int num2) {
  19. String alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  20. String output = alpha.substring((num1 - 1), num2);
  21. return output;}
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement