1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
#include <iostream>
#include <iomanip>
using namespace std;
double getSpools(double, double, double);
void displayOrder(double, double, double);
int main ()
{
double ordered, stock, charges;
cout << fixed << showpoint << setprecision(2);
getSpools(ordered, stock, charges);
displayOrder(ordered, stock, charges);
system ("pause");
return 0;
}
double getSpools(double ordered, double stock, double charges)
{
char specialChargeYN;
cout << "The number of spools ordered: ";
cin >> ordered;
while (ordered < 1)
{
cout << "\n\nInvalid Input.\n\n\nEnter a number higher than 1: ";
cin >> ordered;
}
cout << "\n\nThe number of spools in stock: ";
cin >> stock;
while (stock < 0)
{
cout << "\n\nInvalid Input.\n\n\nEnter a number higher than 0: ";
cin >> stock;
}
cout << "\n\nAny special shipping and handling (Y/N)? ";
cin >> specialChargeYN;
if ((specialChargeYN == 'Y') || (specialChargeYN == 'y'))
{
cout << "\n\nWhat are the special charges per spool? $";
cin >> charges;
while (charges <= 10)
{
cout << "\n\nInvalid Input.\n\n\nEnter a number higher than 10: ";
cin >> charges;
}
}
else if ((specialChargeYN == 'N') || (specialChargeYN == 'n'))
{
charges = 10.00;
}
}
void displayOrder(double ordered, double stock, double charges)
{
double backOrder = 0, ship, perSpool, totalCost, specialCharges;
cout << "\n\nThe number of spools ready to ship from stock: " << ordered;
if (ordered > stock)
{
//I'm trying to get the negative result, then turn it to positive.
backOrder = stock - ordered * (1-2);
cout << "\n\nThe number of ordered spools on back order: " << backOrder;
}
ship = ordered - backOrder;
perSpool = ship * 100.00;
cout << "\n\nThe total selling price of the portion ready to ship $" << perSpool;
specialCharges = ship * charges;
cout << "\n\nThe total shipping and handling charges on the portion ready to ship $" << specialCharges;
totalCost = perSpool + specialCharges;
cout << "\n\nThe total of the order ready to ship $" << totalCost;
cout << "\n\n\n";
}
|