Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 18.117.188.105
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/jmmowatt/../cmsalazar/../thchang/../dcwood/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/jmmowatt/../cmsalazar/../thchang/../dcwood/hw6.cpp
//       Filename:      hw6.cpp
//       Author:        Derek Wood
//       Instructor:    Dr. Wang
//       Compile:       g++ hw6.cpp -o hw6.out
//       Run:           ./hw6.out
//       Goal: Calculates grades and drops the lowest grade 

# include <iostream>

using namespace std;

void Score(int[], bool&);

void Average(int[], int);

int Lowest(int[], int);

int main()
{
	int score[4];
	int total=0;
	bool fail;
	Score(score,fail);
	if (fail == true)
	return 1;
	Average(score,total);
	return 0;
}
	
void Score(int score[], bool& fail)
{
	cout << "Enter the five scores" << endl;
	for(int s=0; s<=4; s++)
	{
		cin >> score[s];
		if(score[s] <0 || score[s] >100)
		{
			cout << "Score is incorrect." << endl;
			fail = true;
		}
	}
}

void Average(int score[], int total)
{
	cout << "The average score after the lowest grade was dropped: " << endl;
	cout << Lowest (score, total) << endl;
}

int Lowest(int score[], int total)
{
	 
    	for (int i= 0; i<=4; i++)        
	{
      		int a, save = score[i];
         	for ( a = i; a >= 1 && score[a - 1] > save; a-- )
       	 		score[a] = score[a - 1]; 
     		score[a] = save;
   	}
	for(int s=1; s<=4; s++)           
        total += score[s]; 
        total = total/4;
	return total;
}

Stv3n404 - 2023