Question
This builds on the first homework. We are adding loops, an if statement, and some totals. Heres the first new part. First, ask the user
This builds on the first homework. We are adding loops, an if statement, and some totals. Heres the first new part. First, ask the user for how many items you have in stock. Read that number into a variable. Now, for each item, do what you did in HW1: ask for the items name, and read that into a variable; then ask for the quantities on the shelf, in the stockroom, and in the warehouse, and read those in. Heres the next new part: ask for the target stock number, and read that in. Now you can add up the amounts on the shelf, stockroom, and warehouse, and see if your total is more than the target, less than, or equal to. Print out a line for that item indicating how much over or under you are. Heres the last new part. As you loop through all of your items, keep a running total of all inventory, and print that out at the end.
Heres a sample run.
Welcome to the Thorpe Grocery. How many items do you have? 2
Name of item: Cookies
How many on shelf, stockroom, warehouse? 10 20 30
What is the target number? 50
Cookies 10 20 30 60 over by 10
Name of item: Broccoli
How many on shelf, stockroom, warehouse? 5 15 25
What is the target number? 50
Broccoli 5 15 25 45 under by 5
Total number of items: 105
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started