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
|
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
void getScore(int &, int &, int &, int &,int &);
void calcAverage(double &);
int findLowest(int &, int &, int &, int &, int &);
int main()
{
int test1 = 0, test2 = 0, test3 = 0, test4 = 0, test5 = 0;
string response;
//double averge;
getScore(test1, test2, test3, test4, test5);
//calcAverage(averge);
cout << "Are there any more test scores?" << endl;
cin >> response;
cout << endl;
if (response == "yes")
{
//getScore(test1, test2, test3, test4, test5);
//calcAverage(averge);
}
system("pause");
return 0;
}
void getScore(int &num1, int &num2, int &num3, int &num4, int &num5)
{
cout << "What was your score for the first test?" << endl;
cin >> num1;
cout << endl;
if (num1 < 1 || num1 > 100)
{
cout<<"Scores must be between 1 and 100, re-enter the score" << endl;
cin >> num1;
}
cout << "What was your score for the second test?" << endl;
cin >> num2;
cout << endl;
if(num2 < 1 || num2 > 100)
{
cout<<"Scores must be between 1 and 100, re-enter the score" << endl;
cin >> num1;
}
cout << "What was your score for the third test?" << endl;
cin >> num3;
cout << endl;
if(num3 < 1 || num3 > 100)
{
cout<<"Scores must be between 1 and 100, re-enter the score" << endl;
cin >> num1;
}
cout << "What was your score for the fourth test?" << endl;
cin >> num4;
cout << endl;
if(num4 < 1 || num4 > 100)
{
cout<<"Scores must be between 1 and 100, re-enter the score" << endl;
cin >> num1;
}
cout << "What was your score for the fifth test?" << endl;
cin >> num5;
cout << endl;
if(num5 < 1 || num5 > 100)
{
cout<<"Scores must be between 1 and 100, re-enter the score" << endl;
cin >> num1;
}
//return num1, num2, num3, num4, num5;
}
void calcAverage(double &average)
{
int number1, number2, number3, number4, number5, lowest;
lowest = findLowest(number1, number2, number3, number4, number5);
cout << lowest << endl;
}
int findLowest(int &num1, int &num2, int &num3, int &num4, int &num5, int &lowest)
{
lowest = num1;
if (num2 < lowest)
{
lowest = num2;
//return lowest;
}
else if (num3 < lowest)
{
lowest = num3;
//return lowest;
}
else if (num4 < lowest)
{
lowest = num4;
//return lowest;
}
else if (num5 < lowest)
{
lowest = num5;
//return lowest;
}
return lowest;
}
|