Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java Write a program that calculates the tax and tip on a restaurant bill. The program should ask the user to enter the charge for
Java
Write a program that calculates the tax and tip on a restaurant bill. The program should ask the user to enter the charge for the meal and how happy they are with the service. The program will then calculate the total bill by adding tax and the appropriate tip. The calculations will be as follows: - The tax should be 7.13% of the meal charge - The tip would depend on how happy the customer is with the service. The happiness value will be between 1 and 5 , one being least happy and 5 being most happy. The Tip percentage will be as follows: Happiness value 1 will attract 5% tip Happiness value 2 will attract 7.5% tip Happiness value 3 will attract 10% tip Happiness value 4 will attract 15% tip Happiness value 5 will attract 20% tip Write a program that calculates the monthly bill for a mobile phone company. As input, the program will accept: - Number of minutes of voice calls made in a month as an integer - Number of text messages sent in a month as an integer - Number of MBs of data used as an integer - Your package code [1-3] There are three packages available: Package code 1: Package code 2: Package code 3: Input (example) Voice call minutes: 101 Text messages sent: 30 MBs of data used : 100 Package Code [13]:1 Output (example) Summary of Usage: You used 101/100 minutes, you exceeded your monthly limit You used 30/150 SMS messages, you are within your monthly limit You used 100/1024 MB of data, you are within your monthiy limit Charges: PackagecodeMonthlychargesAdditionalvoicecharges(1minutee0.20perminute)AdditionalSMScharges(0SMS@0.20persMS)Additionaldatacharges(0MBe0.25perminute)SubTotalStateTax(6.5z)Totaldue=1=10.00=0.20=0.00=0.00=20.20=1.31=21.51 IMPORTANT: 1. Input validation: Check for the negative input values. Print an error message and exit the program if negative values are entered. Zero values are OK as the customer may not have used the mobile phone at all in the whole month. The only acceptable package codes are 1-3. Invalid package codes should result in an error message and the program is terminated 2. The details might seem overwhelming; however, it is a very simple program. You will be using a greater number of variables and will be doing some creative conditional processing using if / else statements. 3. Feel free to take any approach as long as it works 4. The Output should be neatly formatted with all the numbers aligned, as shown in the example above. Consider using tab escape sequence character \t
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