476179

SwitchChar

Nov 4th, 2019
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. package les;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Switch_Char
  6. {
  7.  
  8. public static void main(String[] args)
  9. {
  10. String in;
  11. char food;
  12. Scanner keyboard= new Scanner(System.in);
  13. System.out.println("our pet food comes in three grades: A, B, or C, "
  14. + "enter the one you want pricing for");
  15. in = keyboard.nextLine();
  16. food = in.charAt(0);
  17.  
  18. switch(food)
  19. {
  20. case 'a':
  21. case'A':
  22. System.out.println(".30/lb");
  23. break;
  24.  
  25. case 'b':
  26. case'B':
  27. System.out.println(".20/lb");
  28. break;
  29.  
  30. case 'c':
  31. case'C':
  32. System.out.println(".15/lb");
  33. break;
  34.  
  35. default:
  36. System.out.println("invalid choice");
  37. break;
  38. }
  39.  
  40. keyboard.close();
  41.  
  42.  
  43.  
  44. }
  45.  
  46. }
Add Comment
Please, Sign In to add comment