This is homework so I am not trying to get answers I am just hoping you guys can guide me to the correct path.

Write a program that presents the user with a menu. Option 1 allows the user to enter grades from the keyboard until a negative value is entered. Option 2 displays the mean (average) for the grades. Option 3 displays the standard deviation for the grades. Use the following formula: sdx=sqrt((sumx2-(sumx*sumx)/n)/(n-1)); Option 4 displays the high and low grades. And my personal favorite, option 5, allows the user to end the program.

<code>

#include <iostream>;
using namespace std;

int main ()
{
int choice;
cout << "Please choose one of the following options to continue:\n";
cout << "Option 2: View the mean for the grades entered\n";
cout << "Option 3: Standard devitaion for you're grades\n";
cout << "Option 4: Displays the high and low grades\n";
cout << "Option 5: Quit(enter negative number)\n";
cout << "Enter you're choice (1-5):";
cin >> choice;
cout << "\n";
int total;
if (choice == 1)
{
cout << "Enter you're next choice\n";
cin >> choice;
}
else if (choice == 2)
{
cout << total;
}
else if (choice == 3)
{
}
else if (choice == 4)
{
}
else if (choice == 5)
{
}
system("pause");
}

</code>

Right now I am stuck on option 1 because I can't get my while loop to store those grades so I can use them later on for the average I am not sure how to do that. Thanks =)
It doesn't look like you did any kind of aritmatic for the grades. In option two you just wrote cout<<total, which with the code above is an empty variable. you stored the grades in grades in option 1.

Last edited on
Sorry I meant to erase that I am trying to figure out how to get the mean from the 1st choice I know it's the sum / by the total of numbers like if put in grades; 40, 30, 20 I would do 90/3 but I don't know how to do that in the while loop.
Ohh my bad. The way it seems that this is set up is that it keeps looping back to the begining of the variable so it keeps over writing it. One thing that you could do is have a variable that it keeps looping through like you have but also have another variable outside of the loop and have something like

you have the while loop loop through the variable grades so that you can insert numbers into that then it spits them out into amount.
I made some improvement lol after hrs of trying

<code>
int count = 0;
int sum = 0;
int average = 0;
int sdx = 0;
if (choice == 1)
{
{
count++;
}
{
cout << "Enter you're next choice\n";
cin >> choice;
}
if (choice == 2);
{
average = sum / count;
cout << "The average of the grades enter is:" << average <<"\n";
}
if (choice ==3);
{
sdx = sqrt ((sumx2 - sum * sumx)/count) / (count -1);
cout << sdx;
}
system("pause");
}

</code>

How do you think that looks so far I am trying to figure out the standard deviation part right now Choice 3
Looks good. What is choice 3 doing thats incorrect?

and if you dont mind me asking how many projects have you had so far?
Last edited on
Choice 3 nothing yet I am trying to figure out the standard deviation. This is my 3rd I think it's an online class and the teacher isn't very helpful so I've had to either learn it from the book or just figure it out on my own so I've been struggling a little.
Hey you wouldnt happen to have Kolars would you?
Yeah I do hahha it's hard to get in touch with him.
Topic archived. No new replies allowed.