Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package les;
- import java.util.Scanner;
- public class Switch_Char
- {
- public static void main(String[] args)
- {
- String in;
- char food;
- Scanner keyboard= new Scanner(System.in);
- System.out.println("our pet food comes in three grades: A, B, or C, "
- + "enter the one you want pricing for");
- in = keyboard.nextLine();
- food = in.charAt(0);
- switch(food)
- {
- case 'a':
- case'A':
- System.out.println(".30/lb");
- break;
- case 'b':
- case'B':
- System.out.println(".20/lb");
- break;
- case 'c':
- case'C':
- System.out.println(".15/lb");
- break;
- default:
- System.out.println("invalid choice");
- break;
- }
- keyboard.close();
- }
- }
Add Comment
Please, Sign In to add comment