Server IP : 172.16.15.8 / Your IP : 3.145.91.111 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/kebuck/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// // CS 112 Computer Programming Assignment 5 // // File: hw5.cpp // Author: Katie Buck // Instructor: Dr. Wang // // Compile: g++ hw5.cpp // Run: ./a.out < in5.txt // // Goal: The goal of this program is to read a file with unknown // number of student scores, process the data, and output the // highest, lowest, and average scores to the monitor to one // decimal place. // #include <iostream> #include <iomanip> using namespace std; int main() { cout << fixed << showpoint << setprecision(1); int ch; int sum = 0; int highest = 0; int lowest = 100; int counter = 0; cin >> ch; highest = ch; while(cin) { counter ++; if ( ch > highest ) highest = ch; cin >> ch; if ( ch < lowest ) lowest = ch; sum = sum + ch; } cout << " The average of the scores are " << 1.0*sum/counter << endl; cout << " The highest score is " << highest << endl; cout << " The lowest score is " << lowest << endl; return 0; }