// reading_and_writing_files.cpp #include #include using namespace std; int main() { // *********** declaration statements ************* int weight = 0; int height = 0; int totalWeight = 0; int totalHeight = 0; int numStudents = 0; ifstream infile("C:/Documents and Settings/*****/Desktop/data.txt"); // fill in the asterisks with your PSU username // ************ input statements ****************** while (!infile.eof()) { infile >> weight; totalWeight += weight; infile >> height; totalHeight += height; numStudents++; } ofstream outfile; outfile.open("C:/Documents and Settings/*****/Desktop/output.txt"); // or ofstream outfile("C:/Documents and Settings/*****/Desktop/output.txt"); outfile << "ave weight: " << double (totalWeight)/numStudents << endl; outfile << "ave height: " << double (totalHeight)/numStudents << endl; infile.close(); outfile.close(); return 0; }// end of main