Assume you work in a museum and you have been asked to developa system that char
ID: 3618061 • Letter: A
Question
Assume you work in a museum and you have been asked to developa system that charges customers based on the followingconditions Customers age (0-12 )year =100 dollar age(12-18)years =200dolars Above 18 years =500 dollars Non-Citizens, a flat rate of 1000 dollars Write a program that asks the customer to input age, andproduces a message stating the users price of admission.(Hint :usedialog boxes) Assume you work in a museum and you have been asked to developa system that charges customers based on the followingconditions Customers age (0-12 )year =100 dollar age(12-18)years =200dolars Above 18 years =500 dollars Non-Citizens, a flat rate of 1000 dollars Write a program that asks the customer to input age, andproduces a message stating the users price of admission.(Hint :usedialog boxes)Explanation / Answer
//Hi, here is a complete example solution that implements thenecessary logic. //This program has been tested on the Netbeans 6.8 IDE and isfunctional. //If you have questions feel free to ask via PM. //Import required for dialogs that will be used import javax.swing.JOptionPane; public class Main { public static void main(String[] args) { //Dialog to obtain theage from the user int age =Integer.parseInt(JOptionPane.showInputDialog(null, "Enter Age: ","Input Required", 1 )); //Dialog to obtain userinput for being a citizen String s =JOptionPane.showInputDialog(null, "Is this a citizen? (y/n)","Input Required", 1 ); //check if "citizen" if (s.equals("y")){ //logic to check the age and display the appropriate dialog if (age > 18) JOptionPane.showMessageDialog(null, "Admisson is $500"); if (age 12) JOptionPane.showMessageDialog(null, "Admisson is $200"); if (age = 0) JOptionPane.showMessageDialog(null, "Admisson is $100"); } else JOptionPane.showMessageDialog(null, "Admisson is $1000"); } }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.