Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Thomas Worrell
- 9/23/2019
- Intro to Java Programming CSC-111
- Homework Four
- Output the corresponding number associated with an inputed character
- taworrell0001@student.stcc.edu
- */
- import java.util.Scanner;
- public class LetterInpToNumb
- {
- public static void main(String[] args)
- {
- Scanner input = new Scanner(System.in);
- int x = 1;
- while (x != 0)
- {
- String inbetween = "";
- char entered=' ';
- System.out.println("Welcome to the Character to Number program, using the International Standard.");
- System.out.print("Please enter a character from A-Z: ");
- inbetween = input.nextLine();
- System.out.println("");
- entered = inbetween.charAt(0);
- switch (entered) {
- case 'A':
- case 'a':
- case 'B':
- case 'b':
- case 'C':
- case 'c':
- System.out.println("The number associated with the letter you entered is 2.");
- break;
- case 'D':
- case 'd':
- case 'E':
- case 'e':
- case 'F':
- case 'f':
- System.out.println("The number associated with the letter you entered is 3.");
- break;
- case 'G':
- case 'g':
- case 'H':
- case 'h':
- case 'I':
- case 'i':
- System.out.println("The number associated with the letter you entered is 4.");
- break;
- case 'J':
- case 'j':
- case 'K':
- case 'k':
- case 'L':
- case 'l':
- System.out.println("The number associated with the letter you entered is 5.");
- break;
- case 'M':
- case 'm':
- case 'N':
- case 'n':
- case 'O':
- case 'o':
- System.out.println("The number associated with the letter you entered is 6.");
- break;
- case 'P':
- case 'p':
- case 'Q':
- case 'q':
- case 'R':
- case 'r':
- case 'S':
- case 's':
- System.out.println("The number associated with the letter you entered is 7.");
- break;
- case 'T':
- case 't':
- case 'U':
- case 'u':
- case 'V':
- case 'v':
- System.out.println("The number associated with the letter you entered is 8.");
- break;
- case 'W':
- case 'w':
- case 'X':
- case 'x':
- case 'Y':
- case 'y':
- case 'Z':
- case 'z':
- System.out.println("The number associated with the letter you entered is 9.");
- break;
- case '+':
- System.out.println("The number associated with the character you entered is 0.");
- break;
- default:
- System.out.println("There is no number associated with the charater you entered."
- + "\nPlease be careful of your typing.");
- }
- System.out.println("\nWould you like to run the program again?\n(1 for Yes, 0 for No)");
- x = input.nextInt();
- input.nextLine();
- }
- input.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement