I need the "void get_gas_data_1..." to only display if the user enters ten or more gallons. However, both voids for "get_gas_data" show up no matter what number i put...what should i do to fix this?
void get_gas_data (char &gas_type, int &number_of_gallons)
{
cout <<"Welcome to MSU’s Gas and Go!"<<endl<<endl;
cout << " What type of gas would you like to purchase today? " << endl;
cout << "Please enter R for Regular,M for Mid grade, P for Premium and D for Diesel"<<endl;
cin >> gas_type;
cout << "Now, enter the number of gallons" << endl;
cin >> number_of_gallons;
}
void get_wash_data_1 ( int &ans, char &car_wash_type)
{
cout<< " We give a $ 3.00 car wash discount with the purchase of 10 or more gallons"<<endl;
cout << " Enter 1 to include the car wash of 2 to cancel the car wash and press ENTER" <<endl;
cin >> ans;
}
void get_wash_data_2 ( char &ans_2, char &car_wash_type_2)
{
cout<< " We also give a $ 1.50 car wash discount with the purchase of 5 or more gallons"<<endl;
cout << " Enter Y to include car wash or N to cancel and press ENTER" <<endl<<endl;
cin >> ans_2;
}
Well, we can't see how your code is calling the functions here but based on what we do see, you could do this...
1 2 3 4 5 6 7
void get_wash_data_1 ( int &ans, char &car_wash_type, int number_of_gallons) {
if(number_of_gallons >= 10) {
cout<< " We give a $ 3.00 car wash discount with the purchase of 10 or more gallons"<<endl;
cout << " Enter 1 to include the car wash of 2 to cancel the car wash and press ENTER" <<endl;
cin >> ans;
}
}