Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class CheckAgeForDiscount {
- public static void main(String args[]) {
- Scanner myScanner = new Scanner(System.in);
- int age;
- double price = 0.00;
- char reply;
- System.out.print("How old are you? ");
- age = myScanner.nextInt();
- System.out.print("Have a coupon? (Y/N) ");
- //reply = myScanner.findInLine(".").charAt(0);
- reply = myScanner.next().charAt(); //ben121 @ #java hub.malvager.com
- if (age >= 12 && age < 65) {
- price = 9.25;
- }
- if (age < 12 || age >= 65) {
- price = 5.25;
- }
- if ((reply == 'Y' || reply == 'y') &&
- (age >= 12 && age < 65)) {
- price -= 2.00;
- }
- System.out.print("Please pay $");
- System.out.print(price);
- System.out.print(". ");
- System.out.println("Enjoy the show!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement