Subject Computer Science Java Programming

Question

General Summary: For this assignment, write a Java application that prompts the user for pairs of inputs of a product number (1-5), and then an integer quantity of units sold (these are two separate prompts for input values).

Assignment Description:

Write a Java program to process the 15 items below for a single order. There are five sets of inputs as follows:

Product 1 1 unit (cost is $2.98 per unit)
Product 2 2 units (cost is $4.50 per unit)
Product 3 3 units (cost is $9.98 per unit)
Product 4 4 units (cost is $4.49 per unit)
Product 5 5 units (cost is $6.87 per unit)

You must use a switch statement and a sentinel-controlled loop (i.e., a loop that stops execution when an out of range value, such as -1, is input).

You must show all user inputs, including the product numbers, quantities, and sentinel value. You must also show all program outputs.

Your application must calculate and display the cumulative total order amount after each of the five pairs of input values is entered.

You must also show the total order amount after the sentinel value is entered.

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import java.util.Scanner;

/**
*
* @author
*/
public class Driver {

    public static void main(String[] args) {
       Scanner input = new Scanner(System.in);
       double total = 0.0;
       int option = 0;
       int set;
       int number;
       int quantity;
       int order = 1;
       while (option != -1) {
            int quantities[] = {0, 0, 0, 0, 0, 0};
            set = 0;
            double orderCost = 0.0;
            System.out.printf("Order %d:%n", order);...

This is only a preview of the solution. Please use the purchase button to see the entire solution

$20.00

or free if you
register a new account!

Assisting Tutor

Related Homework Solutions

Get help from a qualified tutor
Live Chats