I have this code and can't kick out of the while with ctrl+Z(it just prints ctrl+Z in my console window. Any ideas ?
#include <iomanip>
#include <ios>
#include <iostream>
#include <string>
using std::cin; using std::setprecision;
using std::cout; using std::string;
using std::endl; using std::streamsize;
int main()
{
cout << "Please enter your first name: ";
string name;
cin >> name;
cout << "Hello, " << name << "!" << endl;
// ask for and read the midterm and final grades
cout << "Please enter your midterm and final exam grades: ";
double midterm, finalexam;
cin >> midterm >> finalexam;
// ask for the homework grades
cout << "Enter all your homework grades, "
"followed by end-of-file: ";
// the number and sum of grades read so far
int number = 0;
double sum = 0;
// a variable into which to read
double x;
// invariant:
// we have read count grades so far, and
// sum is the sum of the first count grades
while (cin >> x) {
++number;
sum += x;
}
//write the result
streamsize prec = cout.precision();
cout << "Your final grade is " << setprecision(3)
<< 0.2 * midterm + 0.4 * finalexam + 0.4 * sum / number
<< setprecision(prec) << endl;
return 0;
}