I did my assignment and lost four points. This is what my professor said.
// -1 indenting – condtionalAndLoopCalcuiations(), WHOLE while() LOOP NOT INDENTED
// -1 reference – VALUES NOT RETURNED AND USED BY CALLER
-1 THERE IS NO INITIAL MESSAGE TO LET THE USER KNOW WHAT TO DO
* ON EXIT, HIGHEST/LOWEST ARE REPEATED – GOODBYE WOULD HAVE BEEN A GOOD MESSAGE
Enter -99 to quit entering.
45
The highest number you entered was 45
The lowest number you entered was 45
Enter -99 to quit entering.
67
The highest number you entered was 67
The lowest number you entered was 45
Enter -99 to quit entering.
23
The highest number you entered was 67
The lowest number you entered was 23
Enter -99 to quit entering.
-99
The highest number you entered was 67
The lowest number you entered was 23
Press any key to continue . . .
-1 KEEP OUT OF USER MESSAGES AS WELL
cout << "Enter -99 to quit entering." << endl;
I'm not quite sure what he's saying or how to correct them in my code, so I was hoping someone could me with this and my other two assignment mistakes.
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
|
//Ashton Dreiling
//Largest and Smallest exercise
#include <iostream>
#include <stdlib.h>
using namespace std;
//module prototype
void condtionalAndLoopCalcuiations (double &number, double &high, double &low, double &couner);
//global constants
const double ZERO_FOR_CALCULATION = 0;
const double NEGATIVE_NINTY_NINE_FOR_CALCULATION = -99;
int main()
{
double number = ZERO_FOR_CALCULATION;
double high;
double low;
double counter = ZERO_FOR_CALCULATION;
condtionalAndLoopCalcuiations(number, high, low, counter);
system("Pause");
return 0;
}//end main
void condtionalAndLoopCalcuiations(double &number, double &high, double &low, double &counter)
{
while (number != NEGATIVE_NINTY_NINE_FOR_CALCULATION)
{
cout << "Enter -99 to quit entering." << endl;
cin >> number;
if (counter == ZERO_FOR_CALCULATION)
{
high = number;
low = number;
counter++;
}//end of conditional statement
else
{ if (number > high && number != NEGATIVE_NINTY_NINE_FOR_CALCULATION)
high = number;
else if (number < low && number != NEGATIVE_NINTY_NINE_FOR_CALCULATION)
low = number;
}//end of conditional statement
cout << "The highest number you entered was " << high << endl;
cout << "The lowest number you entered was " << low << endl;
}//end of which loop statement
}//end of conditionalAndLoopCalculations module
|