Note that there are some explanatory texts on larger screens.

plurals
  1. POC program to calc avg etc
    primarykey
    data
    text
    <p>i wrote this code in class today with the teacher helping me but I'm home now and need guidance, I'm not sure what i should do next to get it to compile atleast</p> <p>the objective is to:</p> <p>create a menu enter a number(option A) dispaly the average (option B) display the highest and lowest number(option C and D) display the total of all numbers entered(option E) display the total amount of numbers entered(option F) and quit(option G)</p> <p>here is what i have so far, i apologies if its messy</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;ctype.h&gt; //int getNumber (aNumber) { // printf("Enter an integer between 0 and 1000.\n"); // scanf("%i", &amp;aNumber); // int result; // } char getMenuLetter(); int getNumber(); //declare variables int aNumber = 0; float avg = 0.0; int high = -1; int low = 1001; int total = 0; int count = 0; char getChoice = 'x'; int main() { //proptotype functions do { getChoice = getMenuLetter(); switch (getChoice) case 'A': aNumber = getNumber(); count++; total += aNumber; low = testLow(aNumber, low) high = testHigh(aNumber, high); break; case 'B'; avg = (double) total/count; //display avg printf("The average is %.2f", avg); break; case 'C': high = getHigh(); printf("The highest value of all the numbers entered is %i.\n", high); //display highest number break; case 'D': low = getLow; printf("The lowest value of all the numbers entered is %i.\n", low); //displayer lowest value break; case 'E': printf("The total of all the numbers entered is %i.\n", total); break; case 'F': printf("The amount of numbers entered so far is %i.\n", count); case 'G'; break: //end switch } while (userChoice != 'G'); } int testLow(int n) { int result; if (n &lt; low) result = n; else return 0; } //End of main char getMenuLetter() { char result; system("cls") //clear the screen. printf("*************************************************\n"); printf("A) Enter a number between 0 and 1,000\n"); printf("B) Display the average\n"); printf("C) Display the highest value entered\n"); printf("D) Display the lowest value entered\n"); printf("E) Display the sum of all numbers\n"); printf("F) Display the count of all numbers entered\n"); printf("G) Quit the program\n"); printf("*************************************************\n"); scanf("%c", &amp;result); result =toupper(result); ///print f %c //system pause if (result != 'A' || result != 'B' || result !='C' || result !='D' || result !='E' || result != 'F' || result !='G'){ printf("You must enter A - G only! \n)"); system("pause"); } //end if } while(result != 'A' || result != 'B' || result !='C' || result !='D' || result !='E' || result != 'F' || result !='G'); return result; //end of GetMenuLetter </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload