Of all things, I can't seem to get my do while loop to work. I have a running program, but get a syntax error : identifier 'choice'

Can't see it, any help greatly appreciated
RG

#include <iostream>
using namespace std;

class Odometer

{
public:
	Odometer();
	void reset();
	void compute_fuel();
	void input_miles(int getmiles);
	void Odometer::set_fuel_efficiency(double fuel_efficiency);
	double Odometer::get_num_gallons();
	int gallons_consumed;


private:
	int miles_tracker;
	double fuel_efficiency;
	int getmiles;
	
	
};


Odometer::Odometer()
{
	
	miles_tracker = 0;
	fuel_efficiency = 0;
	
}



void Odometer::reset()
{
	miles_tracker = 0;
}



void Odometer::compute_fuel()
{
	fuel_efficiency = (miles_tracker/gallons_consumed);
}



void Odometer::input_miles(int miles_driven)
{
	miles_tracker = miles_tracker + miles_driven;

}




void Odometer::set_fuel_efficiency(double Fuel_efficiency)
{
	fuel_efficiency = Fuel_efficiency;
}

double Odometer::get_num_gallons()
{
	return miles_tracker/fuel_efficiency;
}




	 


int main()
{

	Odometer simulator;
	
	char choice;
	int number_of_miles_driven;
    double mpg, num_gallons_used;
    
	do
	{
	 

	cout << "Please enter the amount of miles driven : " << endl;
	cin >> number_of_miles_driven;
	simulator.input_miles(number_of_miles_driven);

	cout << "Please enter the amount of fuel mileage your vehicle is rated at in M.P.G.: " << endl;
	cin >> mpg;

	simulator.set_fuel_efficiency(mpg);
	
	

	simulator.get_num_gallons();
	num_gallons_used = simulator.get_num_gallons();


    cout.setf(ios::fixed);
	cout.setf(ios::showpoint);
    cout.precision(2);
	cout << "Your number of gallons used on this trip is: " << num_gallons_used << " gallon(s)" << endl;

	cout << "Please press y to enter another vehicles mileage or any key to end: " << endl;
	cin >> choice;

	


	
		
	system("pause");

	}while choice == 'y';




return 0;

}
Member Avatar for iamthwee

Don't you need brackets around the while

such as while (choice=='y');

:) That would be it! Thanks for the refresher

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.