in c Write a program that calculates the average of a group

in c++ Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions.

Void getscore() should ask the user for a test scores, store it in a reference parameter variable and validate that it is not lower than 0 or higher then 100 This function should be called by main once for each of the five scores to be entered.

Void calcAverage() should calculate and display the average of the four highest scores. This function should be called just once by main, and should be passed the five scores.

Int findLowest() should find and return the lowest of the five test scores passed to it. It should be called be calcAverage, which uses the function to determine which one of the five scores to drop.

Solution

#include<iostream>

using namespace std;

int main()

{

int a[5];

a=getScore();

double b;

b=calcAverage(a);

return 0;

}

int[] getScore()

{

int a[5];

cout<<\"\ enter 5 scores \";

for(int i=0;i<5;i++)

{

abc:

cout<<\"\ score \"<<i+1<<\":\";

cin>>a[i];

if(!(a[i]>=0&&a[i]<=100))

{

cout<<\"\ enter i range 0 to 100\";

goto abc;

}

}

return a;

}

double calcAverage(int[] a)

{

int min;

min=findLowest(a);

double sum=0.0;

for(int i=0;i<a.length;i++)

{

if(a[i]!=min)

sum+=a[i];

}

double avg;

avg=sum/a.length-1;

return avg;

}

int findLowest(int[] a)

{

int min;

min=a[i];

for(int i=1;i<a.length;i++)

{

if(a[i]<min)min=a[i];

}

return min;

}

in c++ Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functi

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site