Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. class CheckAgeForDiscount {
  4.  
  5. public static void main(String args[]) {
  6. Scanner myScanner = new Scanner(System.in);
  7. int age;
  8. double price = 0.00;
  9. char reply;
  10.  
  11. System.out.print("How old are you? ");
  12. age = myScanner.nextInt();
  13.  
  14. System.out.print("Have a coupon? (Y/N) ");
  15. //reply = myScanner.findInLine(".").charAt(0);
  16. reply = myScanner.next().charAt(); //ben121 @ #java hub.malvager.com
  17.  
  18. if (age >= 12 && age < 65) {
  19. price = 9.25;
  20. }
  21. if (age < 12 || age >= 65) {
  22. price = 5.25;
  23. }
  24.  
  25. if ((reply == 'Y' || reply == 'y') &&
  26. (age >= 12 && age < 65)) {
  27. price -= 2.00;
  28. }
  29.  
  30. System.out.print("Please pay $");
  31. System.out.print(price);
  32. System.out.print(". ");
  33. System.out.println("Enjoy the show!");
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement