Program54.java Write an inventory program for a small retail firm that sells only 4 products. The program should prompt for the unit price and quantity in stock for each product and then print the inventory value of each product. The program should finish by printing the total inventory value. Display commas for thousands as needed in currency outputs as shown. Sample Output

Np Ms Office 365/Excel 2016 I Ntermed
1st Edition
ISBN:9781337508841
Author:Carey
Publisher:Carey
Chapter3: Performing Calculations With Formulas And Functions
Section: Chapter Questions
Problem 2.15CP
icon
Related questions
Question

Program54.java

Write an inventory program for a small retail firm that sells only 4 products. The program should prompt for the unit price and quantity in stock for each product and then print the inventory value of each product. The program should finish by printing the total inventory value. Display commas for thousands as needed in currency outputs as shown.
Sample Output

 

Enter the price and quantity in stock for product 1 24.99 48
Product 1 inventory value is $1,199.52
Enter the price and quantity in stock for product 2 32.95 30
Product 2 inventory value is $988.50
Enter the price and quantity in stock for product 3 44.99 24
Product 3 inventory value is $1,079.76
Enter the price and quantity in stock for product 4 59.99 20
Product 4 inventory value is $1,199.80
Total inventory value is $4,467.58
Transcribed Image Text:Enter the price and quantity in stock for product 1 24.99 48 Product 1 inventory value is $1,199.52 Enter the price and quantity in stock for product 2 32.95 30 Product 2 inventory value is $988.50 Enter the price and quantity in stock for product 3 44.99 24 Product 3 inventory value is $1,079.76 Enter the price and quantity in stock for product 4 59.99 20 Product 4 inventory value is $1,199.80 Total inventory value is $4,467.58
Expert Solution
Step 1

Steps to be followed:

  • Create a class named Program54
    • Define main() method:
      • Create Scanner object.
      • Set total to 0.
      • Run for loop from i = 1 to 4:
        • Print "Enter the price and quantity in stock for product", i
        • Read price and quantity.
        • Calculate inventory value, amount = price * quantity
        • Update total inventory value,  total  = total + amount
        • Print amount
      • Print total
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole