Special Problem for Swap A local zoo wants to keep track of how many pounds of f
ID: 3914470 • Letter: S
Question
Special Problem for Swap A local zoo wants to keep track of how many pounds of food each of its three monkeys eats each day during a typical week. Write a program that stores this information in a two-dimensional 3 x 7 array, where each row represents a different monkey and each column represents a different day of the week. The monkeys are represented by integers 1, 2, and 3; the weekdays are "Sunday", "Monday" "Tuesday". "Wednesday Thursday". Friday". "Saturday The program should first prompt the user to input the data for each monkey, starting with "Sunday" for monkey #1, then monkeys #2 and #3. followed by "Monday" for monkey # 1, then monkeys #2 and #3 and so on, through-Saturday. The program then creates a report that includes the following information, each properly labeled (see below) Average anount of food eaten per day by the whole family of monkeys The least amount of food eaten during the week by any one monkey The greatest amount of food eaten during the week by any one monkey nput Validation: Do not accept negative numbers for pounds of food eaten. When a negative value is entered, the program outputs "invalid negative) food quantity re-enter and attempts to reread the value Prompts And Output Labels: Each item read should be prompted for by a string of the form Enter the food eaten by nonkey N on DAY or "Saturday" where N is 1 or 2 or 3, and DAY is "Sunday" or "Monday" or The output should be of the form: Average food consuned daily by this group of monkeys: 6.23 The least daily food consumed was by Monkey #1 on Friday The most daily food consumed was by Monkey #3 on Sunday where the specific amount of food or specific monkeys or specific days identified depend on the actual input.Explanation / Answer
monkey_array = {1,2,3}
days = {Sunday, Monday, Tuesday, Wednesday, Thrusday, Friday, Saturday}
food[3][7]
//Taking input
for i = 0 to 2
for j = 0 to 6
print “Enter the food Eaten by monkey “ + monkey_array[I] + “on” + days[j]
food[i][j] = input
if(food[i][j] < 0) {
print “invalid(negative) food quantity — re-enter”
continue;
}
//Input complete
//Now we need to find min, max and average
sum_food = 0;
min = INT_MIN;
max = INT_MAX;
min_monkey, min_day, max_monkey, max_day;
for i = 0 to 2
for j = 0 to 6
sum_food = sum_food + food[i][j]
if(min > food[i][j])
min_monkey = i;
min_day = j;
min = food[i][j];
}
if(max < food[i][j])
max_monkey = i;
max_day = j;
max = food[i][j];
}
avg_food = sum_food / 21;
Print “Average food consumed daily by this group of monkeys:” + avg_food
Print “The least daily food consumed was by Monkey “ + monkey_array[min_monkey] + “ on “ + days[min_day]
Print “The most daily food consumed was by Monkey “ + monkey_array[max_monkey] + “ on “ + days[max_day]
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.