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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!