Hey guys :),
Thanks for any help ahead of time.
I'm writing a program that would take the input scores of seven judges and throw out the highest and the lowest.
#include<iostream>
using namespace std;
int main()
{
float a=0, b=0, c=0, d=0, e=0, f=0, g=0, score=0, difficulty=0;
cout << "First Judge Score \n";
cin >> a;
cout << "Second Judge Score \n";
cin >> b;
cout << "Third Judge Score \n";
cin >> c;
cout << "Fourth Judge Score \n";
cin >> d;
cout << "Fifth Judge Score \n";
cin >> e;
cout << "Sixth Judge Score \n";
cin >> f;
cout << "Seventh Judge Score \n";
cin >> g;
if(a < b && c && d && e && f && g)
{
a=0;
}
else if(b < c && d && e && f && g)
{
b=0;
}
else if(c < d && e && f && g)
{
c=0;
}
else if(d < e && f && g)
{
d=0;
}
else if(e <f && g)
{
e=0;
}
else if(f < g)
{
f=0;
}
else
{
g=0;
}
if(a > b && c && d && e && f && g)
{
a=0;
}
else if(b > c && d && e && f && g)
{
b=0;
}
else if(c > d && e && f && g)
{
c=0;
}
else if(d > e && f && g)
{
d=0;
}
else if(e >f && g)
{
e=0;
}
else if(f > g)
{
f=0;
}
else
{
g=0;
}
score= a+b+c+d+e+f+g;
cout << "Total score " << score<< "\n";
Basically, the problem I am having is that when it is making the comparisons is that it isn't checking all the values that are inputted. So, if a = 1.3 and b = 2.6 ..... then a will be set to 0 even if c=1.1 (lower than both a and b). I was wondering if anyone could help me figure out how to make sure the && works to check all the values. I already tried doing it individually i.e. if((a<b) && (a<c) .... etc.)