0%
0 / 6 answered

Introduction to Using Data Sets Practice Test

6 Questions
Question
1 / 6
Q1

A store tracks weekly sales in an int[] and uses totals for restocking decisions. Consider:

In a small bookstore, the manager records the number of mystery novels sold each day for a week to decide how many to reorder. The data set is a fixed-size array because there are always 7 days in a week, and each index represents a day (0 = Monday, 6 = Sunday). By summing the array, the manager estimates demand; by computing an average, the manager decides whether to increase next week’s order. If a late receipt changes Tuesday’s count, the array value must be updated before recalculating totals.


int[] dailySales = {12, 9, 15, 8, 11, 14, 10};

int total = 0;

for (int i = 0; i < dailySales.length; i++) {

    total += dailySales<u>i</u>; // add each day

}

double avg = (double) total / dailySales.length;

Refer to the problem scenario in the passage, what is the value of avg after the code executes?

Question Navigator