Server IP : 172.16.15.8 / Your IP : 3.145.108.43 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 ] |
---|
// CS112 Computer Programming Assignment 7 // // File: hw7.cpp // Author: Katie Buck // Instructor: Dr. Wang // // Compile: g++ hw7.cpp // Run: ./a.out < in7.txt // // Goal: The goal is to write a program that will read the first // 21 scores from a file of student scores, process the data, // and output the highest, lowest, total, and average of the // scores to one decimal place. #include <iostream> #include <iomanip> using namespace std; int main() { cout << fixed << showpoint << setprecision(1); int number; int sum = 0; int biggest = 0; int lowest = 100; int counter = 0; for( int i=1; i<=21; i++) { cin >> number; counter ++; if ( number > biggest ) biggest = number; if ( number < lowest ) lowest = number; sum = sum + number; } cout << "The largest score was a " << biggest << endl; cout << "The lowest score was a " << lowest << endl; cout << "The total of the scores are " << sum << endl; cout << "The average of the scores are " << sum/21.0 << endl; return 0; }