You are going to help me with a program that displays grade statistics. The
program should read any number of grades (up to 100) and ends when the user enters
-1, the program should reject any invalid grade. You should store the numbers in
an array
The program displays the following:
· The number of grades
· The grade average
· The maximum grade
· The minimum grade
· The median grade, which is the middle grade after sorting the grades. If the
number of grades is even, the median is the average of the middle two
grades.
· The standard deviation, calculated as:
standard deviation=
(1/(N-1)*(i=0 to N Σ(xi-m)square))and all to the power 0.5 , where
xi : the grade i
m : the average of grades
N : the number of grades
· The number of passing grades (grade £ 50)
· The number of failing grades (grade < 50)
· An error message if the user enters an invalid grade ( grade > 100 or grade
< 0).
Sure, we'd be happy to help with your homework, but we're not going to do it for you.
Let's start at the very basics: Write a program that reads grades entered by the user into an array.
You will need to:
* Create an array of a type that stores numbers, of a maximum size of 100.
* Create a loop that asks the user to input a grade, then checks if it is valid and if it is indeed valid, stores it in the array.
Come back to us with the code you have for that and then we'll start adding the other functions on top of that.
Please let us know if you require any further explanations.
sorry for my late to answer you
and no its nt a homework
my teacher gave it to me to improve myself in arrays and functions in c++
because im very very week( he didnt knw tht i dont understand because if he knew tht he will get mad) , he told if you wrote this program u will be good enough to write programs
and actully i dont understand arrays and functions, because that i registerd here
* Create an array of a type that stores numbers, of a maximum size of 100.
* Create a loop that asks the user to input a grade, then checks if it is valid and if it is indeed valid, stores it in the array.
Come back to us with the code you have for that and then we'll start adding the other functions on top of that.
At least try to come up with something - this is really very basic stuff.
If you need explanations about certain things, just ask us, but don't ask us to just give you the code, because we won't.
while (x!=-1);
sum=sum+x;
avr=sum/c;
cout<<"number of grades= "<<c<<endl;
cout<<"avr = "<<avr<<endl;
cout<<"max number = "<<max<<endl;
cout<<"min number = "<<min<<endl;
I think you're reading the instructions wrong, what you need to do is initialize double A[100]; because he wants the program to take any number of grades up to 100 student's grades.
There are some issues with your code besides that. you need to put "A[h] = x" inside of the if statement that tests whether the number is acceptable or not.
next try nesting a while loop in there that checks if a number is lower than the numbers entered before it and swaps them if it is.
simple sorting code;
1 2 3 4 5 6 7 8 9 10 11 12
int holder = 0, i = 0;//place this next to the other variables that you declared above
i = h;
while(A[i] < A[i-1])//this will run until the number has been sorted into place
{
holder = A[i-1];
A[i-1] = A[i];
A[i] = holder;
i --;
}
do
{
holder = A[i-1];
A[i-1] = A[i];
A[i] = holder;
i --;
} while(A[i] < A[i-1]);
For help on sorting, I just explained the use of the bubble sort algorithm to someone yesterday in this thread:
http://cplusplus.com/forum/general/89676/
omg this the same homework i have to do hhhhhhh small world but cr8 reference site hhhhhhh i alrdy di the same topic xD .
if i write it i can help u if u want .
good luck