### New programmer, need help!!

//Ive been working with functions and this looks to all be setup correctly but the math is wrong, i'm getting random negative numbers as my answers. I just need a different set of eyes to look at it.
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191`` ``````/* File: lab4.cpp Author: Dennis Hensley Description: This application is an ordering system for wood floors. */ #include using namespace std; bool isValid(char floorType); //Returns if an invalid floor type is entered. int calculateNumBoxes(int squareFeet); //Function that is used to calculate number of boxes. void calculateReceipt(char floorType, int Num_Boxes, double& subtotal, double& tax, double& total, double& downpayment); //Calculates tax, subtotal, total, and down payment. void printReceipt(int Num_Boxes, double subtotal, double tax, double total, double downpayment); //Prints number of boxes, subtotal, total, tax, and down payment. const int SQ_FT_PER_BOX=30; const double LAMINATE_COST=2.59; const double ENGINEERED_COST=3.19; const double WOOD_COST=3.99; const double TAX=0.0925; const double MAX_DOWN_PAYMENT=500; //Declaring constants. int main() { int Num_Boxes; char floorType; double subtotal; double tax; double total; double downpayment; int squareFeet; cout<< "Welcome to Wood Floors R Us!\n"; //Print menu cout<< "To order your flooring, type:\n"; cout<< "\tL:Laminate (\$2.59/sq ft)\n"; cout<< "\tE:Engineered hardwood (\$3.19/sq ft)\n"; cout<< "\tW:Solid wood (\$3.99/sq ft)\n"; cout<< "\tQ:To quit/exit"<> floorType; while (floorType!='Q' && floorType!='q') { isValid(floorType); //If isValid returns true if(isValid(floorType)) { cout<< "Square feet required: "; cin>>squareFeet; //If user enters a negative square feet, print error message while(squareFeet<=0) { cout<< "Square feet must be positive.\n"; cout<< "Square feet required: "; cin>> squareFeet; } //Call functions calculateNumBoxes(squareFeet); calculateReceipt(floorType, Num_Boxes, subtotal, tax, total, downpayment); printReceipt(Num_Boxes, subtotal, tax, total, downpayment); } //If isValid returns false...do this. else { cout<< "Invalid floor type!"; cout<< "To order your flooring, type:\n"; cout<< "\tL:Laminate (\$2.59/sq ft)\n"; cout<< "\tE:Engineered hardwood (\$3.19/sq ft)\n"; cout<< "\tW:Solid wood (\$3.99/sq ft)\n"; cout<< "\tQ:To quit/exit"<> floorType; } //Ask user again for floortype and print menu cout<< "To order your flooring, type:\n"; cout<< "\tL:Laminate (\$2.59/sq ft)\n"; cout<< "\tE:Engineered hardwood (\$3.19/sq ft)\n"; cout<< "\tW:Solid wood (\$3.99/sq ft)\n"; cout<< "\tQ:To quit/exit"<> floorType; } //Print Good-bye message cout<< "Thankyou for your patronage!"<
Last edited on
 I just need a different set of eyes to look at it.

It would be a lot easier to look at if you used code tags. Look for the `<>` button, and feel free to modify the original post to use 'em.
calculateNumBoxes does a calculation and returns a result, but the call to calculateNumBoxes at line 60 never saves the result. When calculateReceipt is called, Num_Boxes is uninitialized.