### Code Cleaning

Looking to figure out what is wrong with my code, running on a simple command prompt through microsoft c++. It is a rewritten code that worked before changing it to functions. It is for a class so format must stay the same, but now when it runs it goes blank so looking for advise. I realized it is missing things and incomplete, more so looking at getting it to start up.

Here is the current code.
 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970`` ``````// Calculates the cost for delivery of packages based on weight, package size, girth, and height. // // Variables Below // cost = the final cost of the delivery of a package (output) // weight = the weight of the package (input) min=0 max=150 (Looked it up!) // girth = the girth of the package (input) // height = the height of the package (input) // package_size = the girth plus the height // cost_per_inch= constant for the cost based on size // cost_per_pound= constant for the cost based on the weight // weight_cost= the cost based on cost_per_pound * weight // size_cost= the cost based on cost_per_inch * package_size // package_cost= the total cost of size_cost + weight_cost // #include #include using namespace std; // cout and cin definitions. void description(); //setting as void void process(); //setting as void void calculated(); //setting as void double weight=45.0; double girth=63.2; double height=13.8; const double cost_per_inch= .25; //setting cost per inch constant const double cost_per_pound= 2.5; //setting cost per pound constant const double package_size=girth + height; //calculate the size const double weight_cost=cost_per_pound * weight; //calculate the cost based on weight const double size_cost=cost_per_inch * package_size; //calculate the cost based on size const double cost_package=weight_cost + size_cost; //total cost of package int main() { void description(); void process(); void calculated(); return(0); } void description() { cout<<"The weight is: "<
Where is void calculated()?
 ``1234`` ``````void process() { cout << setprecision(2); }``````

Look at the example
http://www.cplusplus.com/reference/iomanip/setprecision/
Last edited on
ne555 is correct.

Your calling your functions in main as prototypes with the 'void' in front of it.

They should be called thusly:

 ``1234567`` ``````int main() { description(); process(); output(); return(0); }``````

Furthermore you have an additional closing curly bracket at the final line of your program and I believe you "void calculated();" you have created a prototype for function that does not exist. I think it should be:
`void output();` above your main loop.

Finally look at what maeriden has said about how to use setprecision, it should be set inline with the text you're trying to output.
K thanks, I knew I mixed something up. It was a different code that got mixed in with this one.
Topic archived. No new replies allowed.