/*
Lab Lesson 7 Part 1/2
Write a program for the hypothetical Acme Wholesale Copper
Wire Company. This company sells spools of copper wiring for $104
each—write a program that displays the status of an order.
You will need at least three functions (two other than main).
You must use function prototypes for all functions but main.
*/
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
bool read(); // function prototype for the read function
int display(); // function prototype for the display function
// read function below
bool read(int &spoolsOrdered, int &spoolsInStock, double &shippingAndHandling) {
cout << "Spools to be ordered" << endl;
cin >> spoolsOrdered;
if (spoolsOrdered < 1) {
cout << "Spools must be 1 or more" << endl;
return false; // is this allowed or jut return 0?
}
cout << "Spools in stock" << endl;
cin >> spoolsInStock;
if (spoolsInStock < 0) {
cout << "Spools in stock must be 0 or more" << endl;
return false;
}
string shippingOffered;
cout << "Special shipping and handling (y or n)" << endl;
cin >> shippingOffered;
if (shippingOffered == "y") {
cout << "Shipping and handling amount" << endl;
cin >> shippingAndHandling;
if (shippingAndHandling < 0) {
cout << "The spool shipping and handling charge must be 0.0 or more" << endl;
return false;
}
}
return true;
}
int display (int &spoolsOrdered, int &spoolsInStock, double &shippingAndHandling, int &shipSpool, int &spoolBackOrder, double &subtotal, double &shippingCost, double &totalShippingCharges) {
int main() {
int spoolsOrdered, spoolsInStock, shipSpool, spoolBackOrder;
double shippingAndHandling, subtotal, shippingCost, totalShippingCharges;
read(spoolsOrdered, spoolsInStock, shippingAndHandling);
if (spoolsOrdered > 1) {
display(shipSpool, spoolBackOrder, subtotal, shippingCost, totalShippingCharges);
} // for this display it says no matching function for call to display...why?
2. Your function declarations (prototypes) do not match the parameter list of your function definitions. They need to have the same number of parameters.
You really don't need the prototypes since you define your functions before they are used in main().
3. Your display() function is defined to use 8 parameters, none with defaults. In main() you call the function with 5(!) variables. You are not passing 3 variables the function requires.
Next time include the text of the error(s) you received, our crystal balls are not working.
Thanks so much for the feedback. & about #3 in your reply, I did pass in the 3 other variables the function requires and the problem with it was I'd get the same output that I got from calling the read() function, which was right above display() in the main function...