Click here to Skip to main content
16,023,124 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Cant figure out what's wrong in my code.
My program should take in 8 scores of type double and then return the total point by summing up the scores while not including the lowest and highest.

C++
#include <iostream>
#include <iomanip>

using namespace std;
double a[8];
double max , min=0, sum=0;
int i;
void main ()
{
	cout<<fixed<<showpoint<<setprecision(2);
	cout<<"Enter the eight judges scores \n";
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>a[5]>>a[6]>>a[7];
	max = a[0];
	for (i=1 ; i<=7 ; i++)
	{
		if (a[i] > max)
			max = a [i];
		else if (a[i] <= min)
			min = a [i];
	}
	for (i=0 ; i<=7 ; i++)
	{
		if (a[i]==max || a[i]==min)
			a[i]=0;
	}
	for (i=0 ; i<=7 ; i++)
	{
		sum+= a[i];
	}
	cout<<"The contestant recevies a total of "<<sum<<" points  \n";
}
Posted
Updated 14-Apr-10 0:54am
v3

1 solution

7mesho wrote:
max = a[0];


change to

max = min = a[0];

:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900