我正在尝试编写一个程序,该程序要求获得学费学分以及本科或研究生课程。用户输入学分,然后必须输入U
本科或G
研究生。我的条件语句有问题,如果用户输入U
,则计算和输出本科学分的价格,与研究生类似。我试图U
在 IF 条件下输入,但要么是一个价格,要么是另一个输出。
#include <stdlib.h>
#include <iostream.h>
int main ()
{
const double Under = 380.00 ;
const double Grad = 395.00 ;
char U , G ;
double First, Second, Third, Fourth, Fifth, Sixth ;
cout << endl << endl ;
cout << " To calculate your tuition enter the amount of credits, then enter type of" ;
cout << endl ;
cout << " classes." ;
cout << endl << endl ;
cout << " Enter number of credits. " ;
cin >> First ;
cout << endl << endl ;
cout << " Enter U for Undergraduate or G for Graduate: " ;
cin >> Second ;
cout << endl << endl ;
cout << " Your tuition total is: " ;
Third = First * Under ;
Fourth = First * Grad ;
if ( Second == U )
cout << Third ;
else
cout << Fourth ;
cout << endl << endl ;
system ("Pause");
}