Help finishing a code

not sure how to finish the code.keep getting erros in the last line

#include<iostream>
#include<math.h>
#include<conio.h>
using namespace std;
int main()
{
do{
int a=0;
int b=0;
int c=0;
cout<<"1.- V.W.\n";
cout<<"2.- Nissan \n";
cout<<"3.- Ford\n";
cout<<"4.- Chrysler\n";
cin>>a;

switch(a)
{
case 1:
cout<<"El costo de kilometraje para este carro es de $0.2/km"<<endl;
cout<<"Introduzca la distancia recorrida en kilometros"<<endl;
cin>>b;
c=b*0.2;
cout<<"El costo total de kilometraje es de $"<<c;
break;
case 2:
cout<<"El costo de kilometraje para este carro es de $0.5/km"<<endl;
cout<<"Introduzca la distancia recorrida en kilometros"<<endl;
cin>>b;
c=b*0.5;
cout<<"El costo total de kilometraje es de $"<<c;
break;
case 3:
cout<<"El costo de kilometraje para este carro es de $0.45/km"<<endl;
cout<<"Introduzca la distancia recorrida en kilometros"<<endl;
cin>>b;
c=b*0.45;
cout<<"El costo total de kilometraje es de $"<<c;
break;
case 4:
cout<<"El costo de kilometraje para este carro es de $0.52/km"<<endl;
cout<<"Introduzca la distancia recorrida en kilometros"<<endl;
cin>>b;
c=b*0.52;
cout<<"El costo total de kilometraje es de $"<<c;
break;
case 5:
cout << "Goodbye.\n";
a = 0;
break;

}
}
system("pause");
return 0;
}
the format is

do
{

}while(condition)

you are missing the while.
@hectorpenaloza07

I see a couple of small problems.

1. You have a do{, BUT no while. You could have it as }while (a !=0);
Place this as the line directly above system("pause");, replacing the current '}'

2. You declare the variable c to be an int, but try multiplying it with decimals. Make the variable c to be a double, instead.

3. Move the variables a,b and c, ABOVE the do statement, otherwise they are only seen in the do statement and not for the while part.

This should help tremendously.
Last edited on
thanks a lot to both of you. it's fixed now :D
Topic archived. No new replies allowed.