No return value

So all of my functions work. The problem is assigning a return value so the price adds to a variable each time the user selects a product. Driving me crazy.

//the start
# include <iostream>
# include <cmath>
//the start
# include <iostream>
# include <cmath>
# include <cstdlib>

# include <string>



using namespace std;
bool bContinue;
float total;
float sum;
float products;

int printMenu();
void greetUser();
float getCustomerTotal(char code);
float getItemSubtotal(string itemName, float itemPrice);
float calculateProducts(float products);





int main()
{
float subTotal;
float checkout=0.00;
char selection;
bool exit=false;
int code;


greetUser();

do {
char selection;
float savings;
printMenu();
cin>>selection;
getCustomerTotal(selection);
checkout+=savings;
cout<<products<<endl;
cout<<"Do you wish to continue shopping...select 0 or 1"<<endl;
cin>>exit;
}
while(exit != 0);


cout<<"The total purchases today is: "<<checkout<<endl;
return 0;


}


float getCustomerTotal(char code)
{



float products;
float savings;


{






switch(code)
{

case '1':


{
getItemSubtotal("Socks", 2.5f);



break;

}



case '2':
{

getItemSubtotal("Shirts", 14.00f);


break;
}

case '3':
getItemSubtotal("Shoes", 80.00f);
break;



case '4':

{

cout<<"Invalid selection"<<endl;
break;

}


return savings;
}


}

}

float getItemSubtotal(string itemName, float itemPrice)
{
int quantity;
float savings;


cout <<itemName<<" costs"<<itemPrice<<" per unit"<<" How many would you like"<<endl;
cin>>quantity;
savings=quantity*itemPrice;
cout<<" Items cost: "<< savings<<endl;
calculateProducts(savings);

}


int printMenu()

{
int selection;
cout << "Please select an action from the menu below" << endl;
// display menu
cout<<"My Menu";
cout<<"=======================" << endl;
cout<< "Selection Product Price" << endl;
cout<< "------------------------------------------" << endl;
cout<< "1 Socks 2.50" << endl;
cout<< "3 Shoes 80.00" << endl;
cout<< "2 Shirts 14.00" << endl;
cout<< "4 Go to checkout" << endl;
cout<< "5 - Exit" <<endl<<endl;
cout<< "Enter Selection: ";


}




void greetUser()
//Ask user for name
{
string name;
cout << "Please enter your name ==>";
cin>>name;

//display user name
cout << "Hello! Welcome to the farmers market " + name <<endl;
}



float calculateProducts(float products)
{


double item;
item += (1.5*savings);
cout<<"Your price for these items are \n"<<item<<endl;
return item;
}
indent your code (¿why so much whitespace?)

> The problem is assigning a return value
¿how is that a problem?
float foo = getCustomerTotal(selection);
The return value is placed in int main();? and also maybe it is the IDE that I am working with (DEV C++) but I have tried and I get errors constantly
Just tried it and everything work. Thank you so much. I completely understand now
Topic archived. No new replies allowed.