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
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
Chapter3: Performing Calculations With Formulas And Functions
Section: Chapter Questions
Problem 2.15CP
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
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
- Define main() method:
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
Knowledge Booster
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.Recommended textbooks for you
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole