In gymnastics or diving competitions, each contestant's score is calculated by dropping the lowest and highest scores and then adding the remaining scores. Write a program that allows the user to enter eight judge's score and outputs the points received by the contestant. Format your output with two decimal places.
1
Expert's answer
2011-11-25T10:21:41-0500
# include <iostream.h> # include <iomanip.h> void main(){ float a[8], min, max, res; int i; for (i=0;i<=7;i++){ & cout<<"Enter a score "<<i+1<<": "; & cin>>a[i]; } min = a[0]; max = a[0]; for (i=0;i<=7;i++){ & if (a[i]>max) max = a[i]; & if (a[i]<min) min = a[i]; } res = min + max; cout<<setprecision(3)<<res; }
Comments
Leave a comment