大家好,我是一名刚刚开始编程的FSU学生,我很困惑为什么我的CIN无法正常工作。我知道我的代码看起来很有趣我们不允许使用很多东西,比如while语句等等。我发布了以下代码。我的主要问题是为什么在我输入cin >> QUANTITY;
之后,程序中没有任何事情发生。
cout << "-------------------------------------" << endl;
cout << " FLORIDA STATE UNIVERSITY" << endl;
cout << " Ticket Information Dept." << endl;
cout << "-------------------------------------" << endl;
cout <<""<< endl;
cout <<""<< endl;
cout << "Please, enter your name" << endl;
cin >> name;
cout << "How many Florida State University credits have you completed?" << endl;
cin >> CREDITS;
if (CREDITS <0)
{
cout<< "Bad data recieved." << endl;
}
else
{
if (CREDITS <=30)
{
TICKETAMT=2;
cout <<name << ", you are eligible for "<< TICKETAMT<< " tickets." << endl;
}
else if (CREDITS <=60)
{
TICKETAMT=4;
cout <<name << ", you are eligible for "<< TICKETAMT<< " tickets." << endl;
}
else if (CREDITS <=90)
{
TICKETAMT=6;
cout <<name << ", you are eligible for "<< TICKETAMT<< " tickets." << endl;
}
else
{
TICKETAMT=8;
cout <<name << ", you are eligible for "<< TICKETAMT<< " tickets." << endl;
}
cout << "Are you a Florida resident? Enter (Y)es or (N)o" << endl;
cin >> RESIDENT;
if (RESIDENT !='Y'||RESIDENT !='y'||RESIDENT !='N'||RESIDENT !='n')
{
if (RESIDENT=='Y'||RESIDENT=='y')
{
TIXPRICE=75;
}
else if (RESIDENT=='N'||RESIDENT=='n')
{
TIXPRICE=95;
}
cout << "Each ticket costs $" <<TIXPRICE<< endl;
cout << "How many do you want?" << endl;
cin >> QUANTITY;
if (QUANTITY >TICKETAMT||QUANTITY <0)
{
cout << "Bad data -> number of tickets desired is not in range" << endl;
}
else
{
TOTALPRICE = TIXPRICE * QUANTITY;
}
}
else
{
cout << "Bad data recieved" << endl;
}
}