Я написал эту программу, однако, когда я пытаюсь скомпилировать ее, я получаю синтаксические ошибки.Я не могу найти, где синтаксические ошибки.
Он должен рассчитывать количество секундных прохождений звука в разностных газах, информация предоставлена пользователем.
include <iostream>
#include <fstream>
using namespace std;
int main()
{
int choice, gascount=0,i,sec;
string gas[10],type;
double speed[10],speedd;
ifstream input;
input.open("input.txt");
if(input.fail())
cout<<"file did not open please check it\n";
cin >> gas[gascount++];
while(input)
{
input>>speed[gascount];
input>>gas[++gascount];
}
while(choice!=5)
{cout<<"Choose gas would you like to use\n";
cout<<"1 CarbonDioxide\n";
cout<<"2 Air\n";
cout<<"3 Helium\n";
cout<<"4 Hydrogen\n";
cout<<"5 Exit\n"; //5th cout for exiting program
cin >>choice;
switch(choice) //use swich for user selection of gases
{case 1: type="CarbonDioxide";
break;
case 2: type="Air";
break;
case 3: type="Helium";
break;
case 4: type="Hydrogen";
break;
case 5: system("exit");
default: printf("Illegal input: Try Again\n");
}
i=0;
for(i=0;i<gascount;i++) //loop for number of seconds
if(type.compare(gas[i])==0) //speed travel in gases
{speedd=speed[i];
i=gascount+1;
}
cout<<"You chose "<<type<<endl;
cout<<"how many seconds did the sound travel? ";
cin>>sec;
while(sec<0||sec>30)
{cout<<"must me between 0 and 30\n";
cout<<"how many seconds did the sound travel? ";
cin>>sec;
}
cout<<"The speed of sound through "<<type<<" is "<<speedd*sec*10.<<endl;
}
input.close();
system("pause");
return 0;
}