Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Monkey Business A local zoo wants to keep track of how many pounds of food each

ID: 3763401 • Letter: M

Question

Monkey Business

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 × 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". Theprogram 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 amount 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.


Input 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 .


NOTE: Decimal values should be displayed using default precision, i.e. do not specify precision.

Expected Results

http://i.imgur.com/vVrEfrD.jpg

My Results

http://i.imgur.com/G4W0bma.png

CODE

http://pastebin.com/78YCMUsR

I tried many other code snippets and I cant seem to get any of them to work. This has to be exact when it comes to the string OUTPUT since its for code lab.

Thanks!

Explanation / Answer

In the function getAverage(monkeypunds), you should be multiplying it here, and not adding it.. Like this

average = sum / static_cast<double>(ARRAY_ROW * ARRAY_COLUMN);

The rest of the code is working fine. The getGreateast and getLeast functions are correct, and will give positive results.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote