나는 학교에서 간단한 프로그램을 쓰려고하는데 나는 약간의 문제가있다. 나는 그것을 위해 두번 들어가야한다. 예를 들어 을 입력하면 두 번 입력하면 90이됩니다. 문제를 해결하려면 어떻게해야합니까? 당신이 중괄호의 누락 된 세트를 가지고 있기 때문에 순간두 번 입력해야하는 이유는 무엇입니까?
#include <iostream>
#include <string>
using namespace std;
int main(){
string Cartype, rateoption;
double total, miles, days;
const double CdailyRate=30;
const double PdailyRate=40;
const double FdailyRate=50;
const double CmileRate=0.25;
const double PmileRate=0.35;
const double FmileRate=0.45;
cout<<"Thank you for choosing Car Rite Rental for your rental needs!\n"
<<"\a Before we get started calculating your total owed please remember\n"
<<"that here at Car Rite Rental we havea MINIMUM PAYMENT OF $30.\n\n"
<<"Please enter the type of car you have rented: \n\n"
<<"[please enter corresponding letter] \n"
<<"C-Chevrolet\n"<<"P-Pontiac\n"<<"F-Ford\n";
cin>>Cartype;
cout<<"Please choose your payment option from the following: \n\n"
<<"[please enter corresponding number] \n"
<<"D-Daily Rate\n"<<"M-Mileage Rate\n";
cin>>rateoption;
if(rateoption=="D"||rateoption=="d"){
cout<<"Please enter the number of days you have rented this vehicle: \n";
cin>>days;
}
else
cout<<"Please enter the number of miles traveled in your rental car:\n";
cin>>miles;
if (Cartype=="C"||Cartype=="c" && rateoption=="D"||rateoption=="d"){
total=CdailyRate*days;
cout<<"Your total owed today is: $"<<total<<"\nThank you again for choosing Car Rite Rental!\n";
}
return 0;
}
코드를 포맷하십시오. 우리가 그것을 읽을 수 없다면 당신을 도울 수있는 방법이 없습니다. (읽을 수있는 코드를 쓰는 것 역시 필요한 기술입니다). –