私は、特定のホテルで部屋を借りるコストを計算するプログラムを作成しようとしています。プログラムは、賃貸料、部屋の予約日数、および消費税を尋ねます。私は部屋を借りた時間と部屋の賃貸料の額から割引を計算するためにif文を実装することになっています。 51.「期待される主表現__」は何を意味していますか?
#include <iostream>
using namespace std;
int main()
{
int Reason;
double Rent, totRent;
double SalesTax, calcST;
double TimeDiscount, totDiscount;
int numRooms;
int RentTime;
int tenRooms, twentyRooms, thirtyRooms;
int tenTotal, twentyTotal, thirtyTotal, RegularPricing;
cout << "How much is the cost of renting a room: " << endl;
cin >> Rent;
cout << "Are you staying for a special reason i.e. wedding/conference: " << endl;
cin >> Reason;
cout << "How many days are the rooms going to be booked " << endl;
cin >> RentTime;
cout << "What is the sales tax: " << endl;
cin >> SalesTax;
SalesTax = Rent * SalesTax;
calcST = Rent + SalesTax;
totRent = (Rent * numRooms) + RentTime;
if (Reason = 1)
{
cout << "How many are rooms going to be booked: " << endl;
cin >> numRooms;
}
if (RentTime >= 3)
{
TimeDiscount = .05 * Rent;
totDiscount = Rent + TimeDiscount;
}
if (numRooms >= 10)
{
tenRooms = Rent * .10;
tenTotal = (totRent + calcST) - (tenRooms + totDiscount);
cout << "Your total fee is: $" << tenTotal << endl;
}
if (numRooms >= 11 && <= 20) //45
{
twentyRooms = Rent * .20 * SalesTax * TimeDiscount;
twentyTotal = (totRent + calcST) - (twentyRooms + totDiscount);
cout << "Your total fee is: $" << twentyTotal << endl;
}
if (numRooms >= 21 && >= 30 && >> 30) //51
{
thirtyRooms = Rent * .30 + SalesTax + TimeDiscount;
thirtyTotal = (totRent + calcST) - (thirtyRooms + totDiscount);
cout << "Your total fee is: $" << thirtyRooms << endl;
}
else
{
RegularPricing = Rent * RentTime + SalesTax;
cout << "Your Total Fee is: $" << RegularPricing << endl;
}
cout << "The cost of renting one room is: $" << Rent << endl;
cout << "Number of rooms booked : " << numRooms << endl;
cout << "Days booked: " << RentTime << endl;
cout << "The sales tax is: $" << calcST << endl;
return 0;
}
を使用して試すことができ、https://stackoverflow.com/questions/388242/the-definitive-([良い本を読みます] ^書籍ガイドとリスト) – StoryTeller
^特に、表現が何であるかを読んでください。 –