Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java 1 The Assignment This program will display a menu to the user from which they can choose an option for the sale of one

Java 1

The Assignment

This program will display a menu to the user from which they can choose an option for the sale of one of three products. Once the menu selection is made, the user will be prompted for the quantity of the product that is being purchased. When the quantity has been entered, the program will look up the price of the item. If three or more items of the same type are purchased, a 5% discount will given on the purchase of that item. A tally of total sales are kept as the program and can be viewed from a menu option.

2.1. Specifications

There are several ways in which this program could be written. However, in order to grade for following specifications and to have a clear path to a solution, it is required that you write your program using the specifications below.

Use two separate files with a single class in each one (there could actually be more classes, but two will keep it more manageable).

Name the first file (and class) ProductsSold. This is the one that will have all of the methods other than the main method.

Name the second file TestProductsSold. This file will contain the class that has the main method and the logic which controls the program.

There are three products that are sold from the menu: Widget1, Widget2, and Widget3.

There will be a menu option for each of these items plus options to view sales totals and to exit. On the option to exit, use the System.exit(0) statement.

Use methods to accomplish each of the necessary tasks. For instance, you will need a method to calculate the sales tax, a tally method for each of the three products, a method to look up the price of the product, a method to calculate the discount, a method to display the total sales for all of the products, and a method to display the menu. You may need others as well, depending upon the logic.

Use getters and setters where necessary.

The logic flow will be something like the following:

The user makes a selection from the menu to sell one of the three products.

The user will then be prompted for the quantity of that item.

The program will look up the sales price of that item.

The program will calculate the total sale of the item.

If three or more of those items were purchased, the program will calculate a discount and give the 5% discount.

The tally for the total sales for that item will be updated for this item.

At any time, the user can take the option to display the total sales for each of the three products.

Remember that a method should perform only one task. You would not want to create a method that would do a calculation and display the result. That would be two tasks. Also, name your methods with names that contain action words (think task), like calculate, set, and display. In other words, the name should describe what the method does.
In this program you may decide what methods are necessary and name them according to the guidelines above. Outside of the specifications above, you will design the various aspects of this program.

2.2. Output Format

Meaningful description of the purpose of the program. I will be looking for good descriptions of what your program does. An example of a description might look like the following (not for this program of course): Description: This program accepts input from the keyboard as an amount of a purchase as a double, and calculates a discount based on a customer type using a four-tier percentage scale of 2%, 4%, 6%, and 8%. Output is the amount of the discount rounded to two decimal places and the total purchase less the discount, also rounded to two decimal places.

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

More Books

Students also viewed these Databases questions

Question

Is there any evidence of escalations during previous work?

Answered: 1 week ago