SHARE
TWEET

Untitled

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