can anyone help me with my program?
Hi everyone. I'm trying to write a program for a college course I'm taking. It is supposed to simulate a driving a car (it's VERY basic). Well, when I compile my program I get two errors...
prog20.cc: In function `int main()':
prog20.cc:86: parse error before `{' token
prog20.cc: At global scope:
prog20.cc:100: parse error before `while'
in this function...
void displayMenu(int &choice)
{ //This is line 86
do
{
cout << "--- CAR SIMULATOR 1.0 ---" << endl;
cout << " 1 --> Drive Car" << endl;
cout << " 2 --> Refuel Car" << endl;
cout << " 3 --> Crash Car" << endl;
cout << " 4 --> Buy a New Car" << endl;
cout << " 5 --> Paint Car" << endl;
cout << " 0 --> Quit..." << endl;
cout << endl << "Enter the number of an option: ";
cin >> choice;
if(choice < 0 || choice > 5)
cout << "unknown command..." << endl;
}while(choice < 0 || choice > 5); // This is line 100
}
... and I cant figure them out. Probably something really basic that I just keep overlooking... Can anyone help? If you need more of the code just ask and I'll post it. Thanks
[1468 byte] By [
nick53182] at [2007-11-11 7:25:47]

# 5 Re: can anyone help me with my program?
Here ya go... my program up to the errors.
#include <iostream>
#include <string>
using namespace std;
struct Vehicle
{
int year;
string model;
string color;
int miles;
float mpg;
float gas;
float tank;
};
void displayMenu(int &);
void printVehicle(Vehicle &);
void initVehicle(Vehicle &);
void driveVehicle(Vehicle &);
void refuelVehicle(Vehicle &);
void crashVehicle(Vehicle &);
void readVehicle(Vehicle &);
void paintVehicle(Vehicle &);
bool quit();
int main()
{
int choice;
cout << endl;
Vehicle v1;
initVehicle(v1);
bool done = false;
while(!done)
{
printVehicle(v1);
displayMenu(choice);
if(choice == 1)
{
driveVehicle(v1);
}
if(choice == 2)
{
refuelVehicle(v1);
}
if(choice == 3)
{
crashVehicle(v1);
}
if(choice == 4)
{
readVehicle(v1);
}
if(choice == 5)
{
paintVehicle(v1);
}
if(choice == 0)
{
done = quit();
}
return 0;
}
void displayMenu(int &choice)
{ //THIS IS LINE 86
do
{
cout << "--- CAR SIMULATOR 1.0 ---" << endl;
cout << " 1 --> Drive Car" << endl;
cout << " 2 --> Refuel Car" << endl;
cout << " 3 --> Crash Car" << endl;
cout << " 4 --> Buy a New Car" << endl;
cout << " 5 --> Paint Car" << endl;
cout << " 0 --> Quit..." << endl;
cout << endl << "Enter the number of an option: ";
cin >> choice;
if(choice < 0 || choice > 5)
cout << "unknown command..." << endl;
}while(choice < 0 || choice > 5); //THIS IS LINE 100
}
...(there is more to the program but its left out for space)