display issues

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?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
    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;
		
	}
sorry...i meant get_wash_data
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;
    }
}


But what is the second parameter being used for?
its being used for if number_of_gallons is less than 10 or greater or equal to 5
when i put that if statement in i get an error saying "number_of_gallons unidentified".....will seeing my entire code help?
when you call the function you must supply number_of_gallons.

An example...

get_wash_data_1 (ans, car_wash_type, number_of_gallons);

But yes... seeing more of the code would help.
Topic archived. No new replies allowed.