這是我在turbo C++中編寫過的程序,基本上我已經說過它來計算購買特定數量的汽油或柴油的公升;問題是它沒有單獨顯示汽油和柴油,請運行它並告訴我我做了什麼錯誤?C++ /加油站或汽油泵程序
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
double amount,res;
char ch;
cout<<"Welcome to Bharat Petroleum"<<endl;
cout<<"Press P for Petrol and D for Diesel:"<<endl;
cin>>ch;
{
if (ch=='P')
cout<<"Enter your Amount:"<<endl;
cin>>amount;
res=(amount/68)*1;
cout<<"Petrol purchased in litres:"<<endl<<res;
}
{
if (ch=='D')
cout<<"Enter your Amount:"<<endl;
cin>>amount;
res=(amount/48)*1;
cout<<"Diesel purchased in litres:"<<endl<<res;
}
getch();
}
//其中汽油是68個盧比(INR)/升和柴油是48 //
你是什麼意思,「它不是單獨顯示汽油和柴油」 –
檢查你的{}。他們追求如果。 –
你有沒有聽說過縮進? – rburny