SPECIFICATIONS For this homework (Hwk07-Re-stocking XuMart\'s Inventory, Again).
ID: 645470 • Letter: S
Question
SPECIFICATIONS For this homework (Hwk07-Re-stocking XuMart's Inventory, Again). we will use loops to re-stork XuMart's inventory but this time only with needed items. XuMart's delivery van arrives with an unknown numbers of crates of merchandise. Each sate is filled with only one type of item and every item in a crate has exactly the same price. Each crate has a barcode that shows the name of the items ill the crate, the number of items in the crate, and the price per item in the crate. Each crate has between 1 and 100 items. XuMart's has only two rules about pricing: (a) the price of each item In a crate is between ten cents and $100 and (b) if the price is more than $10 then the XuMart employees don't unload that crate. Lots of crates can be on the delivery van that are not unloaded. The only crates XuMart needs are crates that have items priced less than $10. The XuMart employees will skip any crates that have items that rue $10 or more. The user provides no input to this program instead all values must by randomly generated (we are acting like the XuMart employee is merely scanning the barcode.) The delivery truck has lots of crates. The XuMart employees continually unload crates while the total price a an unloaded items is low than $10,000. Once the delivery van has unloaded the needed crates, your pogrom should display total number of crates unloaded, the total number of skipped crates, and the total price of the unloaded items. OBJECTIVES By the end of this homework you should he able to Decide a programming schedule so you finish this program by the due date. Incrementally develop a solution to an involved problem statement. Properly use loops.Explanation / Answer
// Hwk07-Xmart-Inventory restocking program
#include <stdio.h>
#include <stdlib.h>
//Generating Random scanned item price using Bar code
float scanItemPrice()
{
return rand()%100; // returns random price between 0.00 cents to $100
}
int main()
{
int totalUnloaded=0,totalSkipped=0;
float itemInCrate;
float maxItemPrice=0;
while(maxItemPrice<10000) // Maximum unloaded total price is $10000
{
itemInCrate=scanItemPrice(); // getting random Crate Item
printf(" Bar code reader Scanned Item price %f",itemInCrate);
// Unloading only 0.00 to 100
if(itemInCrate>=0.10 && itemInCrate<=100)
{
maxItemPrice+=itemInCrate;
totalUnloaded++;
}
else // Total count of skipped items
totalSkipped++;
}
//Printing
printf(" Total Unloaded Crate items : %d",totalUnloaded);
printf(" Total Skipped Crate items : %d",totalSkipped);
printf(" Total Price of Unloaded Crate items : %f",maxItemPrice);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.