//Programming Fundamentals ONLINE //Chapter 6 Programming Challenges #13- Order Status //Create program with two functions //First function takes input from user and stores in reference parameters //Second function uses arguments to display totals //validate: no less than 1 for spools ordered & no less than 0 spools in stock //and no less than 0 for shipping and handling #include #include using namespace std; void getSpoolInv(double&, double&, double&); double spoolOrdered, spoolStock, addlCharges; void displayTotals(); int main() { cout << endl; cout <<"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; cout <<"++++++++++++++Welcome to My Spool Order Status Program.++++++++++++++\n"; cout <<"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; cout <<"This program will calculate total inventory and total charges.\n"; getSpoolInv(spoolOrdered, spoolStock, addlCharges); displayTotals(); return 0; } //*********************************************************************** //definition of getSpoolsInv //will store spool inventory and charges in spoolOrdered, spoolStock, addlCharges //validates: no less than 1 for spools ordered & no less than 0 spools in stock //and no less than 0 for shipping and handling //*********************************************************************** void getSpoolInv(double &spoolOrdered, double &spoolStock, double &addlCharges) { cout <<"---------------------------------------------------------------------\n"; cout << "Please enter number of spools ordered (cannot be less than 1): "; cin >> spoolOrdered; while (spoolOrdered <1) { cout <<"Number cannot be less than 1, enter again: "; cin >> spoolOrdered; } cout << "Please enter number of spools in stock (cannot be less than 0): "; cin >> spoolStock; while (spoolStock <0) { cout <<"Number cannot be less than 0, try again: "; cin >> spoolStock; } cout <<"---------------------------------------------------------------------\n"; cout << "Every shipment is subject to $10.00 shipping and handling charges.\n"; cout << "Enter extra shipping & handling charges (cannot be less than $0): $"; cin >> addlCharges; while (addlCharges <0) { cout <<"Cannot be less then $0, enter again: $"; cin >> addlCharges; } } //*********************************************************************** //definition of displayTotals //figures totals for program and displays all totals //*********************************************************************** void displayTotals() { double shipTotal, backOrder, totalSelling, totalSH, readyShip; if (spoolStock>spoolOrdered) { readyShip=spoolOrdered; cout <<"---------------------------------------------------------------------\n"; cout <<"Spools Ready To Ship: " << readyShip << endl; } else { backOrder=spoolOrdered-spoolStock; cout <<"---------------------------------------------------------------------\n"; cout <<"Not enough spools in Stock to complete order.\n"; cout <<"Spools Ready to Ship: " << spoolStock << endl; cout <<"Spools on Back Order: " << backOrder << endl; readyShip=spoolStock; } totalSelling = readyShip * 100; totalSH = readyShip *(10+addlCharges); cout <<"---------------------------------------------------------------------\n"; cout <<"Total Selling Price of Spools Ready To Ship: $" << fixed << setprecision(2) << totalSelling << endl; cout <<"Total Shipping & Handling of Spools Ready To Ship: $" << fixed << setprecision(2) << totalSH << endl; cout <<"Total Order Ready To Ship: $" << fixed << setprecision(2) << totalSelling + totalSH << endl; cout <<"---------------------------------------------------------------------\n"; }