Logical Operators + Ifs Small Problems

Pages: 12
closed account (oG8qGNh0)
So I have officially finalized everything.

#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;

int main()
{
char status;
int c;

cout << "Number credits: ";
cin >> c;
if (c > 17) {
cout << "Error: Max credits is 17\n";
return 0;
}
else if (c < 0) {
cout << "Error: Entered negative credits\n";
return 0;
}

cout << "Resident(R)/Non-Resident(N): ";
cin >> status;

if (c >= 12) {
cout << "Student is Full time\n";
}
else {
cout << "Student is Part time\n";
}

double tuition;

tuition = ( status == 'R' ) * min( 360.0 * c, 5389.5 ) + ( status == 'N')* min( 1387.0 * c, 18445.5 );

cout << fixed;
cout << std::setprecision(2);
cout << "Tuition is: " << setprecision(2) << tuition << "\n";

}

Hope this helped
Topic archived. No new replies allowed.
Pages: 12