Question: Main ( ) method instructions - Prompt the user to enter the total number of tables served. - Use the enterOrders ( ) method to
Main method instructions
Prompt the user to enter the total number of tables served.
Use the enterOrders method to initialize an array of doubles containing the total purchased by each table.
Pass the number of tables as a parameter.
Use the calculateDiscounts method to initialize another array of doubles containing the discount granted to each table.
Pass the array with the total purchased by each table and the number of tables as parameters.
Use the calculateTotalDiscounts method to get the sum of all discounts granted during that night.
Pass the array of discounts and the number of tables as parameters.
Use the calculateTotalSales method to get the sum of the total purchased by all tables during that night.
Pass the array with the total purchased by each table and the number of tables as parameters.
Call the printData method to write all results on the console.
Pass the array containing the total purchased by each table, the array of discounts, the sum of all discounts granted during that night, the sum of the total purchased by all tables during that night, and the number of tables as parameters.
Other methods:
enterOrders
This method takes the number of tables as a parameter and returns an array of doubles. The method should use a loop to prompt the user to enter the total purchased by each table and store them in an array of doubles. When the user finishes entering the values, the array is returned.
calculateDiscounts
This method takes two parameters:
An array of doubles containing the total purchased by each table
The number of tables served
The method uses a loop to calculate the discount granted to each table using the following information:
Total Purchased Per Table Discount Percentage
Less than $
From $ to $ inclusive
More than $ to $ inclusive
More than $ to $ inclusive
More than $
The method returns an array of doubles containing the discount amount granted to each table.
Note: The position of the discount amount in the array matches the position of the order purchased in the other array.
calculateTotalDiscounts
This method takes the array of discounts and the number of tables as parameters.
uses a loop to calculate the sum of all discounts granted and returns a double with the sum.
calculateTotalSales
This method takes the array with the total purchased by each table and the number of tables as parameters. It uses a loop to calculate the sum of total purchased by all tables and returns a double with the sum.
printData
This method returns no value, and takes five parameters:
The array containing the total purchased by each table,
The array of discounts,
The sum of all discounts granted during that night,
The sum of the total purchased by all tables during that night, and
The number of tables
The method should print to the console the following, each on its own line:
Table # and the amount purchased by that table
Discount: and the corresponding discount amount granted to that table
The method repeats that as many times as tables are entered. Then, the method prints
Total discount granted during the night: and the total discount granted during that night
Total sales for the night: and the total sales for the night
Grand Total: and totals sales for the night minus the total discounts granted during that night All numbers must be formatted to two decimals.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
