SHARE
TWEET

Untitled

a guest Oct 20th, 2019 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
  7. taworrell0001@student.stcc.edu
  8.  */
  9.  
  10. import java.util.Scanner;
  11.  
  12. public class LetterInpToNumb
  13. {
  14.  
  15.     public static void main(String[] args)
  16.     {
  17.         Scanner input = new Scanner(System.in);
  18.         int x = 1;
  19.  
  20.         while (x != 0)
  21.         {
  22.             String inbetween = "";
  23.             char entered=' ';
  24.             System.out.println("Welcome to the Character to Number program, using the International Standard.");
  25.             System.out.print("Please enter a character from A-Z: ");
  26.             inbetween = input.nextLine();
  27.             System.out.println("");
  28.  
  29.             entered = inbetween.charAt(0);
  30.  
  31.             switch (entered) {
  32.             case 'A':
  33.             case 'a':
  34.             case 'B':
  35.             case 'b':
  36.             case 'C':
  37.             case 'c':
  38.                 System.out.println("The number associated with the letter you entered is 2.");
  39.                 break;
  40.  
  41.             case 'D':
  42.             case 'd':
  43.             case 'E':
  44.             case 'e':
  45.             case 'F':
  46.             case 'f':
  47.                 System.out.println("The number associated with the letter you entered is 3.");
  48.                 break;
  49.  
  50.             case 'G':
  51.             case 'g':
  52.             case 'H':
  53.             case 'h':
  54.             case 'I':
  55.             case 'i':
  56.                 System.out.println("The number associated with the letter you entered is 4.");
  57.                 break;
  58.  
  59.             case 'J':
  60.             case 'j':
  61.             case 'K':
  62.             case 'k':
  63.             case 'L':
  64.             case 'l':
  65.                 System.out.println("The number associated with the letter you entered is 5.");
  66.                 break;
  67.  
  68.             case 'M':
  69.             case 'm':
  70.             case 'N':
  71.             case 'n':
  72.             case 'O':
  73.             case 'o':
  74.                 System.out.println("The number associated with the letter you entered is 6.");
  75.                 break;
  76.  
  77.             case 'P':
  78.             case 'p':
  79.             case 'Q':
  80.             case 'q':
  81.             case 'R':
  82.             case 'r':
  83.             case 'S':
  84.             case 's':
  85.                 System.out.println("The number associated with the letter you entered is 7.");
  86.                 break;
  87.  
  88.             case 'T':
  89.             case 't':
  90.             case 'U':
  91.             case 'u':
  92.             case 'V':
  93.             case 'v':
  94.                 System.out.println("The number associated with the letter you entered is 8.");
  95.                 break;
  96.  
  97.             case 'W':
  98.             case 'w':
  99.             case 'X':
  100.             case 'x':
  101.             case 'Y':
  102.             case 'y':
  103.             case 'Z':
  104.             case 'z':
  105.                 System.out.println("The number associated with the letter you entered is 9.");
  106.                 break;
  107.  
  108.             case '+':
  109.                 System.out.println("The number associated with the character you entered is 0.");
  110.                 break;
  111.  
  112.             default:
  113.                 System.out.println("There is no number associated with the charater you entered."
  114.                         + "\nPlease be careful of your typing.");
  115.             }
  116.             System.out.println("\nWould you like to run the program again?\n(1 for Yes, 0 for No)");
  117.             x = input.nextInt();
  118.             input.nextLine();
  119.         }
  120.  
  121.         input.close();
  122.     }
  123.  
  124. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top