Question: Consider the following code segment that is designed to calculate the average score from a game: int sum = /* some number representing the total
Consider the following code segment that is designed to calculate the average score from a game:
int sum = /* some number representing the total of all the scores */ int count = /* some number representing the number of games played */
Which statement will correctly calculate the average score of all the games?
-
double average = count / sum;
double average = count / sum;
-
double average = (double) sum / count;
double average = (double) sum / count;
-
double average = sum / double (count)
double average = sum / double (count)
-
double average = double (sum / count);
double average = double (sum / count);
-
double average = sum / count;
double average = sum / count;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
