endless input

Its causing me to put in endless input, never outputting anything from the loop, any ideas? I am also going to be spooling out the output, so i know some of it looks unorganized, i just want it to be outputting the right thing before i set up the spool.

#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;

int main()
{
double avgCost, cHours, cost, SSN, students, y, addAmt;
char instate;

cout << "How many students do you have to input?";
cin >> students;
cout << "Please input you social security number, followed by a y\n(for if you live instate)";
cout << "or a n (for if you live out of state),\nand finally type in your credit hours.\n";
y = 0;
avgCost = 0;

cout << "Social Security Number" << " " << "Tution Cost" << " " << "Overall Tution";
{

while (y < students)

cin >> SSN >> instate >> cHours;

{if (instate == 'Y' || instate == 'y')
{if (cHours >= 12)
cost = 1764;
else
cost = cHours + 147;}
else if (cHours >= 12)
cost = 7296;
else
cost = 608 * cHours;}

{if (cHours > 6)
addAmt = 112.50;
else
addAmt = cHours * 18;}

cost = cost + 45 + addAmt;
avgCost = cost + avgCost;

cout << left << setw(25) << SSN << setw(14) << fixed << setprecision(2) << cost;

++y;
}

cout << setw(40) << avgCost;

return 0;
}
Last edited on
Registered users can post here. Sign in or register to post.