Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include using namespace std; bool readFunction(int &spoolsOrdered, int &spoolsInStock, double &shipHandling) { bool invalid = 1; char specialShip; cout < < fixed < <

#include #include using namespace std;

bool readFunction(int &spoolsOrdered, int &spoolsInStock, double &shipHandling) { bool invalid = 1; char specialShip; cout << fixed << setprecision(2);

cout << "Spools to be ordered "; cin >> spoolsOrdered; if(spoolsOrdered <= 0) { cout << "Spools order must be 1 or more "; return invalid;

}

cout << "Spools in stock "; cin >> spoolsInStock; if(spoolsInStock < 0) { cout << "Spools in stock must be 0 or more "; return invalid; }

cout << "Special shipping and handling (y or n) "; cin >> specialShip;

if(specialShip == 'y') { cout << "Shipping and handling amount "; cin >> shipHandling; } else { shipHandling = 11.88; }

if(shipHandling < 0) { cout << "The spool shipping and handling charge must be 0.0 or more "; return invalid; } return 0; }

void displayFunc(int spoolsOrdered, int spoolsInStock, double shipHandling) { double readyShip, readyShipTotal, shippingCharge; int backOrder;

cout << "Spools ready to ship: " << spoolsInStock << endl; backOrder = spoolsOrdered - spoolsInStock; cout << "Spools on back-order: " << backOrder << endl; readyShipTotal = spoolsInStock*100; cout << "Subtotal ready to ship: " << "$" << setw(10) << fixed << setprecision(2) << readyShipTotal << endl; shipHandling*=spoolsInStock; cout << "Shipping and handling: " << " $" << setw(10) << fixed << setprecision(2) << shipHandling << endl;

shippingCharge = readyShipTotal + shipHandling; cout << "Total shipping charges: " << "$" << setw(10) << shippingCharge << endl;

}

int main() { int spoolsOrdered, spoolsInStock; double shipHandling;

bool valid = readFunction(spoolsOrdered,spoolsInStock, shipHandling); if(!valid)

displayFunc(spoolsOrdered, spoolsInStock, shipHandling);

return 0; }

****************************************

This is the input

10

11

y

0 999999.99

This is what should output:

Spools to be ordered

Spools in stock

Special shipping and handling (y or n)

Shipping and handling amount Spools ready to ship: 10

Spools on back-order: 0

Subtotal ready to ship: $ 1000.00

Shipping and handling: $ 0.00

Total shipping charges: $ 1000.00

Although it outputs something way differently

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Inductive Databases And Constraint Based Data Mining

Authors: Saso Dzeroski ,Bart Goethals ,Pance Panov

2010th Edition

1489982175, 978-1489982179

More Books

Students also viewed these Databases questions

Question

=+What is the nature of the unions in the particular country?

Answered: 1 week ago