1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
#include <iostream>
#include <iomanip>
using namespace std;
// FUNTION PROTOTYPES------------------------------------------------------------------------------
void acceptData(float &score);
void averageScore(float a,float b,float c,float d,float e,float f );
int highestRating(float a,float b,float c,float d,float e,float f );
int lowestRating(float a,float b,float c,float d,float e,float f );
// MAIN FUNCTION-----------------------------------------------------------------------------------
int main()
{
float score1 = 0, score2 = 0, score3 = 0, score4 = 0, score5 = 0, score6 = 0;
acceptData(score1);
acceptData(score2);
acceptData(score3);
acceptData(score4);
acceptData(score5);
acceptData(score6);
averageScore(score1, score2, score3, score4, score5, score6);//order functions and calls correctly
highestRating(score1, score2, score3, score4, score5, score6);
lowestRating(score1, score2, score3, score4, score5, score6);
system("PAUSE");
return 0;
}
// FUNTCTION THAT ACCEPTS AND STORES DATA----------------------------------------------------------
void acceptData(float &score)
{
cout << "Please enter users rating: " << endl;
cin >> score;
if (score < 1 || score > 5)
{
cout << "Rating must be between 1 and 5. Enter score: " << endl;
cin >> score;
}
}
// FUNTION THAT COMPUTES THE AVERAGE SCORE---------------------------------------------------------
void averageScore(float a,float b,float c,float d,float e,float f )
{
float average;
average = (a + b + c + d + e + f)/6;
cout << "Average rating for the 6 users is: " << average << endl;
}
//FUNCTION RETURNS THE HIGHEST OF THE USERS RATINGS------------------------------------------------
int highestRating(float a,float b,float c,float d,float e,float f)
{
float highest;
cout<<endl;
if (a > b && a > c && a > d && a > e && a > f)
{
highest = a;
}
if (b > a && b > c && b > d && b > e && b > f)
{
highest = b;
}
if (c > a && c > b && c > d && c > e && c > f)
{
highest = c;
}
if (d > a && d > b && d > c && d > e && d > f)
{
highest = d;
}if (e > a && e > b && e > c && e > d && e > f)
{
highest = e;
}
if (f > a && f > b && f > c && f > d && f > e)
{
highest = f;
}
cout << "The highest rating is: " << highest << endl;
}
// FUNCTION RETURNS THE LOWEST OF THE USER INPUT---------------------------------------------------
int lowestRating(float a,float b,float c,float d,float e,float f)
{
float lowest;
cout<<endl;
if (a < b && a < c && a < d && a < e && a < f)
{
lowest = a;
}
if (b < a && b < c && b < d && b < e && b < f)
{
lowest = b;
}
if (c < a && c < b && c < d && c < e && c < f)
{
lowest = c;
}
if (d < a && d < b && d < c && d < e && d < f)
{
lowest = d;
}if (e < a && e < b && e < c && e < d && e < f)
{
lowest = e;
}
if (f < a && f < b && f < c && f < d && f < e)
{
lowest = f;
}
cout <<"The lowest rating is: " << lowest << endl;
}
|