Question

Write a Java application that prompts the user for pairs of inputs of a product number...

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 (this is two separate prompts for input values). 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). All 15 items below are for a single purchase. 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)

Your application must show the user’s input of each pair of product number and quantity, the calculated line cost for that product, and the cumulative order cost so far. Then, after the sentinel value is input your program must display the total retail cost for the full order.

You must show all 11 user inputs (5 product number and quantity pairs and the sentinel value) and all the corresponding program outputs, not just a subset of the inputs and outputs.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

please upvote ?⭐ if you like my answer.

Output


Add a comment
Know the answer?
Add Answer to:
Write a Java application that prompts the user for pairs of inputs of a product number...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A mail order house sells five different products whose retail prices are: product 1: $2.98 product...

    A mail order house sells five different products whose retail prices are: product 1: $2.98 product 2: $4.50 product 3: $9.98 product 4: $4.49 product 5: $6.87. Write a program that reads a series of pairs of numbers as follows: a) product number b) quantity sold Your program should use a switch statement to determine the retail price for each product. Your program should calculate and display the total retail value of all products sold. Use a sentinel-controlled loop to...

  • C# programming Create an application that prompts the user for a storm windspeed in mph, then...

    C# programming Create an application that prompts the user for a storm windspeed in mph, then determines the correct typhoon category. The program must run all test cases of storm windspeed in one execution. Use a sentinel value to terminate the program. Do not assume a specific number of inputs. Determine the maximum storm windspeed value input. Note that the maximum must be evaluated within your program. You MAY NOT use C built in function. Output screenshot must include the...

  • Amail-order housesellsfivedifferentproductswhoseretailpricesareasfollows:product1, $2.98; product 2, $4.50; product 3, $9.98; product 4, $4.49; and product 5, $6.87....

    Amail-order housesellsfivedifferentproductswhoseretailpricesareasfollows:product1, $2.98; product 2, $4.50; product 3, $9.98; product 4, $4.49; and product 5, $6.87. Write a script that reads a series of pairs of numbers as follows: a) Product number b) Quantity sold for one day(html)

  • Write a program that prompts the user to input daily rainfalls and display the total and...

    Write a program that prompts the user to input daily rainfalls and display the total and average rainfall. Use a sentinel controlled loop with sentinel value of -1.   Your output values should only have three digits after the decimal point. Test your program with following input data. 0.31 0.0 0.52 0.79 1.15 1.23 0.93 0.0 0.0 -1 The output of the program should be: The total rainfall is : 4.930 The average rainfall is : 0.547 Copy and paste your...

  • Write a program which: - prompts the user for 2 numerical inputs - stores their two...

    Write a program which: - prompts the user for 2 numerical inputs - stores their two inputs in variables as floats - Use a while in loop to ask a user for a valid operation: (if the user's input operation isn't one of those listed above, instead print a message telling them so, and continue asking for the valid operation) - prompts the user for an arithmetic operation ( + - * / %) - stores the user's input as...

  • 1. Write a program that prompts the user to enter three integers and display the integers...

    1. Write a program that prompts the user to enter three integers and display the integers in non-decreasing order. You can assume that all numbers are valid. For example: Input Result 140 -5 10 Enter a number: Enter a number: Enter a number: -5, 10, 140 import java.util.Scanner; public class Lab01 { public static void main(String[] args) { Scanner input = new Scanner(System.in);    } } ---------------------------------------------------------------------------------------------------------------------------- 2. Write a program that repeatedly prompts the user for integer values from...

  • in java Write an application that: 1. Prompts the user for a number of trials to...

    in java Write an application that: 1. Prompts the user for a number of trials to perform (I will call this "N"). This operation should be type-safe for integers. 2. Simulates N trials of rolling two dice and finding the sum. 3. Uses an array to keep track of how many times each outcome has been rolled (you do not need to keep track of the actual rolls themselves). 4. Computes the percentage of the total number of rolls for...

  • Write a Java program that prompts the user for the page size used in a virtual...

    Write a Java program that prompts the user for the page size used in a virtual memory system; this will be a power of two between 512 (29) and 16384 (214), inclusive. Your program should check the user input for page size to make sure it is one of the allowable inputs (must be a power of 2 and cannot be smaller than 512 or larger than 16384), and should then prompt the user for a virtual address (assume 32-bit...

  • Can I get the answers in Java, please? Write an application that prompts a user for...

    Can I get the answers in Java, please? Write an application that prompts a user for the number of years the user has until retirement and the amount of money the user can save annually. If the user enters a 0 or a negative number for either value, reprompt the user until valid entries are made. Display the amount of money the user will have at retirement. The total amount of money the user will have can be calculated with...

  • Write a Java console application that prompts the user to enter the radius of a circle,...

    Write a Java console application that prompts the user to enter the radius of a circle, then prints its radius, diameter, circumference, and area. Write a JavaFX GUI application to do the same calculation, and draw the circle. The Console Output Enter the radius of the circle: 1.2 The radius is 1.2 The diameter is 2.4 The circumference is 7.5398223686155035 The area is 4.523893421169302 Write and document your program per class coding conventions. Add an instance variable double radius. Generate...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT