Guest User

Untitled

a guest
Oct 20th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. /*
  2. Thomas Worrell
  3. 9/23/2019
  4. Intro to Java Programming CSC-111
  5. Homework Four
  6. Output the corresponding number associated with an inputed character(REVISED WITHOUT LOOPS)
  7. */
  8.  
  9. import java.util.Scanner;
  10.  
  11. public class LetterInpToNumbv2
  12. {
  13.  
  14. public static void main(String[] args)
  15. {
  16. Scanner input = new Scanner(System.in);
  17.  
  18. String inbetween = "";
  19. char entered=' ';
  20. System.out.println("Welcome to the Character to Number program, using the International Standard.");
  21. System.out.print("Please enter a character from A-Z: ");
  22. inbetween = input.nextLine();
  23. inbetween = inbetween.trim();
  24. System.out.println("");
  25.  
  26. entered = inbetween.charAt(0);
  27.  
  28. switch (entered)
  29. {
  30. case 'A':
  31. case 'a':
  32. case 'B':
  33. case 'b':
  34. case 'C':
  35. case 'c':
  36. System.out.println("The number associated with the letter you entered is 2.");
  37. break;
  38.  
  39. case 'D':
  40. case 'd':
  41. case 'E':
  42. case 'e':
  43. case 'F':
  44. case 'f':
  45. System.out.println("The number associated with the letter you entered is 3.");
  46. break;
  47.  
  48. case 'G':
  49. case 'g':
  50. case 'H':
  51. case 'h':
  52. case 'I':
  53. case 'i':
  54. System.out.println("The number associated with the letter you entered is 4.");
  55. break;
  56.  
  57. case 'J':
  58. case 'j':
  59. case 'K':
  60. case 'k':
  61. case 'L':
  62. case 'l':
  63. System.out.println("The number associated with the letter you entered is 5.");
  64. break;
  65.  
  66. case 'M':
  67. case 'm':
  68. case 'N':
  69. case 'n':
  70. case 'O':
  71. case 'o':
  72. System.out.println("The number associated with the letter you entered is 6.");
  73. break;
  74.  
  75. case 'P':
  76. case 'p':
  77. case 'Q':
  78. case 'q':
  79. case 'R':
  80. case 'r':
  81. case 'S':
  82. case 's':
  83. System.out.println("The number associated with the letter you entered is 7.");
  84. break;
  85.  
  86. case 'T':
  87. case 't':
  88. case 'U':
  89. case 'u':
  90. case 'V':
  91. case 'v':
  92. System.out.println("The number associated with the letter you entered is 8.");
  93. break;
  94.  
  95. case 'W':
  96. case 'w':
  97. case 'X':
  98. case 'x':
  99. case 'Y':
  100. case 'y':
  101. case 'Z':
  102. case 'z':
  103. System.out.println("The number associated with the letter you entered is 9.");
  104. break;
  105.  
  106. case '+':
  107. System.out.println("The number associated with the character you entered is 0.");
  108. break;
  109.  
  110. default:
  111. System.out.println("There is no number associated with the charater you entered."
  112. + "\nPlease be careful of your typing.");
  113. }
  114.  
  115. input.close();
  116. }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment