Advertisement
Guest User

Untitled

a guest
Oct 20th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. import java.util.Scanner;
  2. //Ethan Cha Creating a phone keypad and assigning them to letters
  3. public class Hw7P02 {
  4.  
  5. public static void main(String[] args) {
  6. Scanner in = new Scanner(System.in);
  7.  
  8. //ask for user input
  9. System.out.print("Enter input: ");
  10. String numbers = in.next();
  11. //makes it so that if they enter upper case, it returns as lowercase
  12. String number = numbers.toLowerCase();
  13. //makes it so that they can only enter 10 characters, no more no less
  14. for(int number = 0; number.length() < 10; number++ ){
  15. if((aa == 'a') || ( aa == 'b') || ( aa == 'c')){
  16. aa = '2';
  17. }
  18. else if((aa == 'd') || (aa == 'e') || (aa == 'f')){
  19. aa = '3';
  20. }
  21. else if((aa == 'g') || (aa == 'h') || (aa == 'i')){
  22. aa = '4';
  23. }
  24. else if((aa == 'j') || (aa == 'k') || (aa == 'l')){
  25. aa = '5';
  26. }
  27. else if((aa == 'm') || (aa == 'n') || (aa == 'o')){
  28. aa = '6';
  29. }
  30. else if((aa == 'p') || (aa == 'q') || (aa == 'r') || (aa == 's')){
  31. aa = '7';
  32. }
  33. else if((aa == 't') || (aa == 'u') || (aa == 'v')){
  34. aa = '8';
  35. }
  36. else if((aa == 'w') || (aa== 'x') || (aa == 'y') || (aa == 'z')){
  37. aa = '9';
  38. }
  39. }
  40. System.out.println("Phone Number: " + "(" + aa + ab + ac + ")" + ad + ae + af + "-" + ag + ah + ai + aj);
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement