SelF-service Cash Register. solved

Objectives: a) Indefnite loops, b) Summing and counting, c) Named constant, d)data types int, double, String, e)data validation, F) designing and using methods.This program works like a SelF-service Cash Register. A customer may purchase anumber oF items, some are taxable, and some are not. The customer operating theregister inputs a price oF 0.00 to end the sentinel controlled loop. ±or each item,the customer answers a yes/no question to indicate iF the item is taxable. The yes/no question is to be answered by just typing a single letter (y or n) or the wordsyes or no. The user may type this response in upper or lower case. The programmaintains two accumulator (summing) variables, one to add up the prices For alltaxable items and one to add up the prices oF non-taxable items. Once the datainput loop is over, the program calculates the tax due on the total price oF taxableitems. The tax rate is to be defned as a named constant with value 0.0725(7.25%). Since the result From the tax computation may result in a number withmore than 2 decimal digits, this result should be rounded to the nearest penny (2digits aFter decimal point). See later For the code oF a Function (method) that youmay use For this purpose. Other double values calculated may also have round-oFFerrors, so they should also be rounded to 2 decimal digits. The program displays asummary oF all the purchased items (see the sample output). Also, use the 'printF'method to make sure that all money amounts are displayed using 2 digits aFterdecimal point.Program input•Data input using a sentinel control loop:o Indefnite number oF item prices (terminated by a sentinel value oF 0.00).o ±or each non-zero item price, its tax status (y or n). The user may alsotype yes or no.Program output: A sample output is included here.Program operationThe program's operation as seen by the user consists oF:1.Prints a sign-on message identiFying the assignment number and your name2.Prints a short description oF what the program does

Prompts for and read the Frst item price4.Run a sentinel control loop. Within the loopa. ask if the item is taxable and get user's responseb. update appropriate accumulator variable based on the answer to thequestion above (use if-else)c. update item counterd. prompt for and read the next item price (which may be the sentinel ornot)5.After the loop terminates, calculate and display the summary information6.Print the customary sign-off message.Methods you should implement (standard version)void ringUpItems() – This method is called by 'main' method. It does the most ofthe work mentioned in items 3, 4 (parts a – d), 5 mentioned above. Itdeclares and maintains the required counter and accumulator (summing)variables.void showSummary(int itemCount, double taxableTotal, double nonTaxableTotal)– This method is called by the method above to calculate and display thesummary (item 5 above). It displays the 3 values it receives (see sampleoutput); it also calculates the sales tax and the total due from the customerand displays those values as well.Note: The response to the yes/no question is to be accepted into a String variable.Use just its Frst character (charAt() method is useful) to decide the tax status. Soif that Frst character is 'Y' or 'y' then the item is taxable, otherwise the item is nottaxable.Data validation requirements•The item prices cannot be negative. If the user enters a negative value thenthe user is informed of the fact and asked to reenter the value.•The response to the yes/no question must start with 'y', 'Y', 'n', or 'N'. If theuser response starts with any other character then the user is informed ofthe fact and asked to reenter the value
Powered by