Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write a java program .- In a comment, give a general explanation of what your program does. As the programming questions get more complex, the

image text in transcribed

image text in transcribed

write a java program

.- In a comment, give a general explanation of what your program does. As the programming questions get more complex, the explanations will get lengthier. .- Include comments in your program describing the main steps in your program. . - Display a welcome message which includes your name(s). .- Display clear prompts for users when you are expecting the user to enter data from the keyboard. . - All output should be displayed with clear messages and in an easy to read format. . - End your program with a closing message so that the user knows that the program has terminated. In this assignment you are required to write a Cashier Calculator, which will compute the total price of some items including taxes (GST & QST). The sub-total, taxes, and total price are calculated as follows: D=10p(i) where n = number of items bought and P(i) = the price of item i, GST = Subtotal Grate where GRate is the GST tax rate (e.g., GRate=0.06 stands for 6%) QST = (Subtotal + GST) - QRate where QRate is the QST tax rate (e.g., QRate=0.075 stands for 7.5%). Note, unlike other provinces in Canada, QST is applied on top of the sum of the subtotal and GST. Total = SubTotal + GST + QST Your program will require the user to enter the following: 1) The number of items; 2) The price of each item; 3) The GRate in percentage; 4) The QRate in percentage. The following constraints are given: .- The minimum number of items is 1 and the maximum number of items is 10. . - The minimum price of each item is $1 and the maximum price of each item is $1,000. The price may be a decimal number. . - The minimum tax rate for GST is O and the maximum tax rate for GST is 14. Suppose the tax rate if 12.345%, the user is expected to enter "12.345". You will have to divide the entered value by 100 to compute GRate, We assume that the user will not enter the "%" symbol. - The minimum tax rate for QST is 0 and the maximum tax rate for QST is 17. Suppose the tax rate if 12.345%, the user is expected to enter 12.345". You will have to divide it by 100 to compute QRate. We assume that the user will not enter the "%" symbol. - Note, all these minimum and maximum values are constants, i.e., they remain unchanged throughout the entire program. You should know how to define them! The program must behave in the following manner: .- The program will require the user to enter the needed values one after another. If any of the entered values is invalid, then the program will detect that and go into a loop requiring the user to enter a valid value. The program must keep track of the total number of invalid values that the user has entered. Using Subtotal and GRate, the program should compute GST. Using GST and QRate, the program should compute QST. The program will calculate the Subtotal, GST, QST and Total, then display the following: o How many times the user has entered invalid values for all the required inputs. If the user did not enter any invalid value, then no message should be displayed. In other words, "You have entered O invalid inputs" should NOT be di if the user entered all values correctly. 0. The subtotal o. The GST 0. The QST n. The total o D=10p(i) where n = number of items bought and P(i) = the price of item i, GST = Subtotal Grate where GRate is the GST tax rate (e.g., GRate=0.06 stands for 6%) QST = (Subtotal + GST) * QRate where QRate is the QST tax rate (e.g., QRate=0.075 stands for 7.5%). Note, unlike other provinces in Canada, QST is applied on top of the sum of the subtotal and GST. Total = SubTotal + GST + QST Your program will require the user to enter the following: 1) The number of items; 2) The price of each item; 3) The GRate in percentage; 4) The QRate in percentage. The following constraints are given: .- The minimum number of items is 1 and the maximum number of items is 10. .- The minimum price of each item is $1 and the maximum price of each item is $1,000. The price may be a decimal number. .- The minimum tax rate for GST is 0 and the maximum tax rate for GST is 14. Suppose the tax rate if 12.345%, the user is expected to enter "12.345". You will have to divide the entered value by 100 to compute GRate. We assume that the user will not enter the "%" symbol. .- The minimum tax rate for QST is 0 and the maximum tax rate for QST is 17. Suppose the tax rate if 12.345%, the user is expected to enter "12.345". You will have to divide it by 100 to compute QRate. We assume that the user will not enter the "%" symbol. .- Note, all these minimum and maximum values are constants, i.e., they remain unchanged throughout the entire program. You should know how to define them! The program must behave in the following manner: .- The program will require the user to enter the needed values one after another. If any of the entered values is invalid, then the program will detect that and go into a loop requiring the user to enter a valid value. The program must keep track of the total number of invalid values that the user has entered. .- Using Subtotal and GRate, the program should compute GST. .- Using GST and QRate, the program should compute QST. The program will calculate the Subtotal, GST, QST and Total, then display the following: o. How many times the user has entered invalid values for all the required inputs. If the user did not enter any invalid value, then no message should be displayed. In other words, "You have entered O invalid inputs" should NOT be displayed if the user has entered all values correctly. 0. The subtotal o. The GST 0. The QST 0. The total All output values must be formatted. You are ONLY allowed to use printf(). The displayed subtotal, GST, QST, and total should have 2 decimal places. They have to align by their decimal point. The output should look like: Please enter the number of items bought [1...101: 11 Please enter the number of items bought [1...10]: 2 Please enter the price of item 1 [1...1000]: -5 Please enter the price of item 1 (1...1000]: 200 Please enter the price of item 2 (1...1000]: 600 Please enter the tax rate of GST in % (0...14]: 105 Please enter the tax rate of GST in % (0...14]: 6 Please enter the tax rate of QST in % (0...17]: -5 Please enter the tax rate of QST in % 10...17): 7.5 You have entered 4 invalid inputs. Sub Total: $ 800.00 GST: $ 48.00 QST: S 63.60 Total: S 911.60

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions

Question

4. What decision would you make and why?

Answered: 1 week ago

Question

3. Review the evidence. Do you believe the testimony presented?

Answered: 1 week ago

Question

1. What are the marketing implications of this situation?

Answered: 1 week ago