Code:
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
int x, y, z;
cout<<"Enter semester code or \"q\" to quit > "<<endl;
// actually, any non-numeric character will break out of the loop
while (cin >> x)
{
// if ((x / 10) >= 0 && (x / 10) <= 50)
// y = (x / 10) + 2000;
// else if ((x / 10) == 1 || (x /10) >= 51)
// y = (x / 10) + 1900;
// isn't x/10 always >= 0?
// where you break between 1900's & 2000's is arbitrary, right?
// isn't this simpler:
if (x/10 <= 50)
y = x/10 + 2000;
else y = x/10 + 1900;
z = x % 10;
// you had some unneeded brackets
cout << "Semester" <<" "<< " Code" <<right <<endl;
if (x % 10 == 1)
cout << "Fall, "<< y - 1<<" "<< setw(3) << setfill('0')<< x <<right <<endl;
if (x % 10 ==2)
cout << "Spring, "<< y << " "<<setw(3) <<right << setfill('0') << x <<endl;
if (x % 10 == 3)
cout << "First Summer, "<< y << " "<<setw(3) << right << setfill('0') << x <<endl;
if (x % 10 == 4)
cout << "Second Summer, "<< y << " "<<setw(3) << right << setfill('0') << x <<endl;
cin.ignore(); // this discards the newline characters entered by user
// then, prompt for the next entry before exiting loop
cout<<"Enter code or \"q\" to quit > "<<endl;
}
return 0;
}