Write a program that uses an integer array to store 12 test scores that a user enters. Then
1.Calculates the highest score
2.Use following formula to calculate and display the new scores: (original score)/(highest score)*100 (hint: make sure to get the decimal number). Only display the whole number part of the new score.
3.Calculate the average the new scores.
4.Calculate and display the difference between each new score and the average of new scores.
Can someone please help me out, with this question, I'm have hard time doing it..
Thank you.
Write a program that uses an integer array to store 12 test scores that a user enters
So an integer array with 12 elements ok that's easy int scores[12]; there, so now what...
Calculate the highest score
ok so i need a way to go through all these elements and figure out which element is the highest, hmm what is the first thing that comes in mind... well a loop could help me do that, i can loop through all these elements using a for loop (or any loop) and check which element is the largest using an if statement, syntax should look something like this:
1 2 3 4 5 6 7 8 9 10 11
int scores[12] = {1,5,3,4,6,7,8,2,4,10,2,4,2}; Edit://Added additional element, thanks for spotting my mistake.int temp = 0;
for ( int i = 0 ; i < 13 ; ++i )
{
if (scores[i] > temp)
{
temp = scores[i];
}
}
cout<<"The Largest score in is " <<temp<<endl;
i will leave the rest for you, like i said move through the questions step by step and you'll solve them eventually, if you've been paying attention during class that is :)
EDIT: If you want the user to enter the 12 elements of the array you can do it also with a loop, like this:
1 2 3 4 5
for ( int i = 0 ; i < 13; ++i )
{
cout<<"Enter the value of the element at position #"i": ";
cin>>scores[i];
}