Hey guys, I am taking a Logic and Programming course at my local community college and am studying C++. I am stuck on a lab assignment that asks you to enter five scores then find the lowest score and the highest score and then find the average of the excluded scores so it should end up looking like..
Please enter five scores.
First score: 15.7
Second score: 14.2
Third score: 14.8
Fourth score: 15.5
Fifth score: 15.0
Lowest score: 14.2
Highest score: 15.7
Average score with highest score and lowest score excluded: 15.1
Press any key to continue . . .
All I receive for right now is
Please enter five scores.
First score: 15.7
Second score: 14.2
Third score: 14.8
Fourth score: 15.5
Fifth score: 15.0
lowest score : 0
highest score: 15.7
Why isn't my lowest score found?? and is there any easier way to do what I am doing? Thanks!
#include <cstdlib>
#include <iostream>
usingnamespace std;
int main()
{
//Declare variables
double a = 0.0;
double b = 0.0;
double c = 0.0;
double d = 0.0;
double e = 0.0;
double lowest=0.0;
double highest=0.0;
//Request input
cout << "Please enter five scores."<<endl;
cout << "First score: ";
cin >> a;
cout << "Second score: ";
cin >> b;
cout << "Third score: ";
cin >> c;
cout << "Fourth score: ";
cin >> d;
cout << "Fifth score: ";
cin >> e;
//Determine the lowest score
if (a < b && a < c && a<d && a<e)
{
lowest=a;
}
elseif (a > b && a > c && a>d && a>e)
{
highest=a;
}
elseif (b < a && b < c && b < d && b < e)
{
lowest=b;
}
elseif (b > a && b > c && b > d && b > e)
{
highest=b;
}
elseif (c < a && c < b && c < d && c < e)
{
lowest=c;
}
elseif (c > a && c > b && c > d && c > e)
{
highest=c;
}
elseif (d < a && d < b && d < c && d < e)
{
lowest=d;
}
elseif (d > a && d > b && d > c && d > e)
{
highest=d;
}
elseif (e > a && e > b && e > c && e > d)
{
highest=e;
}
else
{ (e < a && e < b && e < c && e < d);
lowest=e;
}
//Display the lowest and highest scores
cout << "Lowest Score: "<<lowest<< endl;
cout << "Highest Score: "<<highest<<endl;
system("pause");
return 0;
}
Yeah, we have never been exposed to that in class. As of right now that is going over my head but I could learn and attempt to use that for this assignment.