Question
Java Program: Please correct my solution: Please enter the customers age : 68 Please enter the customers county : Clermont Output: Ticket price is $20.00
Java Program: Please correct my solution:
Please enter the customers age : 68
Please enter the customers county : Clermont
Output: Ticket price is $20.00
My output is:
Ticket price is $15.00 ( Not Needed) Ticket price is $20.00
------------------------------------------------------------------------
Second, we want to give discounts to people from other counties as follows.
Children under 14 from Clermont County get an 18% discount (from the base price of $40).
Senior citizens (>= 65) from Campbell County get an additional 7.5% discount above and beyond their
normal senior citizen discount. That is, calculate the standard senior discount and then you can perform
a calculation such as amount = amount * .925; (assumes that the calculate price was stored in a variable
named amount). import java.util.Scanner; public class DisAge { public static void main(String[] args) { Scanner in = new Scanner(System.in); Scanner scanner = new Scanner(System.in); System.out.println("Please enter the customers age : "); long age = in.nextLong(); System.out.println("Please enter the customers county:"); String county = scanner.nextLine(); System.out.println(county); double Final_price; double Base_ticket = 30.00; double Base_ticket_Now = 40.00 ; double discount_Rate = 0.50; Final_price = Base_ticket * discount_Rate; in.close(); scanner.close(); if (age < 5){ System.out.println("Ticket price is $0.00"); } if (age >= 65) { String number1AsString = String.format("Ticket price is $%.2f", Final_price); System.out.println(number1AsString); } if(age < 65 && county.equalsIgnoreCase("Boone")) { String number2AsString = String.format("Ticket price is $%.2f", Base_ticket_Now); System.out.println(number2AsString); } if ((age >= 65) && county.equalsIgnoreCase ("Clermont")) { System.out.println("Ticket price is $20.00"); } else{ System.out.println("Sorry but this is not a recognized age!"); System.exit(0); } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started