So, basically my program is suppose allow the user to enter a number(s) for a menu. Display an average, highest number, lowest number, total of numbers entered so far, and how many numbers that have been entered.
What I have highlighted in red, is where my Dev C++ compiler stops. I really do need help on this
Code:#include <ctype.h> // to use the upper function #include <stdio.h> #include <stdlib.h> char getMenuChoice(); int getNumber(); int main() { //Declare variables here int aNumber = 0; float average = 0.0; int high = -1; int low = 1001; int total = 0; int count = 0; char getChoice = ' '; do{ getChoice = getMenuChoice(); switch (getChoice) { case 'A': aNumber = getNumber(); total += aNumber; count++; if (aNumber = getNumber) high = aNumber; if (aNumber < low) low = aNumber; printf(" Inside of A\n"); break; case 'B': average = (double)total / count; printf("The avg is %.2f\n"); system("pause"); break; case 'C': printf("The Highest Value WAS %i\n", high); system("pause"); break; case 'D': prinf("The Lowest Number is %i\n", low); system("pause"); break; case 'E': printf("Inside of E\n"); break; case 'F': prinf("Inside of F\n"); break; case 'G': printf("Inside of G\n"); break; }//End switch } while (getChoice != 'G'); system("pause"); return 0; } // end of Main char getMenuChoice() { char result, choice = ' '; while (result != 'A' && result != 'B' && result != 'C' && result != 'D' && result != 'E' && result != 'D' && result != 'E' && result != 'F' && result != 'G'); system("cls"); //clear the screen printf("*********************************\n"); printf("A) Enter a number between 0 and 1000\n"); printf("B) Display the average\n"); printf("C) Display the Highest Number\n"); printf("D) Display the Lowest Number\n"); printf("E) Display the total of all numbers entered so far\n"); printf("F) Display how many numbers were entered during the session\n"); printf("G) Quit the program\n"); scanf("%c",&result); result = toupper(result); if (result != 'A' && result != 'B' && result != 'C' && result != 'D' && result != 'E' && result != 'D' && result != 'E' && result != 'F' && result != 'G') { printf("You must enter A - G only \n"); system("pause"); }//End IF return result; }//End of getMenuChoice int getNumber() { int result = -1; while (result < 0 || result > 1000) printf("Enter a number between 0 and 1000: "); scanf("%i", &result); if (result < 0 || result > 1000) { printf("You must enter a number between 0 and 1000\n") system("pause") }// End IF



LinkBack URL
About LinkBacks



