Question
C++ programming Lab 4: Monkey Lab Chapter 7: Using one-dimensional and two dimensional arrays 50 points You will be using arrays to track the food
C++ programming Lab 4: Monkey Lab
Chapter 7: Using one-dimensional and two dimensional arrays
50 points
You will be using arrays to track the food intake of 3 adorable monkeys for one week. After filling a 1 dimensional array with monkey names and a 2 dimensional array with food data, you will calculate and report very important statistics about the monkeys. This is cutting edge science!
Step 1)
Declare 2 global constants: NUM_ MONKEYS = 3;
NUM_DAYS = 7;
In main, declare a one-dimensional string array that will hold the names of 3 monkeys. (make up your own names for your monkeys and be creative..you may not use mine!)
In main, declare a 2 dimensional array that will hold the amount of food (in pounds) that each of the three monkeys have eaten in a period of 7 days. **Be sure to use my test data.
Step 2)
Fill the arrays
Options for filling the arrays:
Option1:
Declare the name array, initializing the array with the word none for all three names.
Declare the 2 dim array using 0 as the initial values for all 21 days.
Call a function and use a loop to ask the user for the monkeys names.
In the same function, ask the user for the pounds of food eaten by each of the 3 monkeys for the seven days.
Use this format: Enter the pounds eaten by monkey #1 on day #1:
Enter the pounds eaten by monkey #1 on day #2:
etc
Validate input for negative input.
**Use my test data for input.
Option 2:
Read the data from a file
Declare the 2 arrays and read the data from files.
Create 2 files with the correct data and save them to your project.
Call a function that reads the files using a loop.
Be sure to check if the files exist.
Upload .txt files as well as the .cpp code and screenshot.
Step 3)
Create a function that prints the contents of the two arrays in this format:
Name Day 1 Day 2 Day 3 Day 4 Day 5 Day 6 Day 7
Bonnie 45 33 55 66 77 88 100
Clyde 88 77 66 55 44 33 22
Trigger 44 55 11 66 77 88 99
In the function heading, declare both arrays as constant arrays.
Format as closely as possible, but dont obsess too much over perfection.
Step 4)
Create a function that calculates and displays the average daily food intake for each of the three monkeys. In that function, display the averages with one number to the right of the decimal point. Report the results in the following format:
Name Average daily intake in pounds
Bonnie (report the results)
Clyde etc.
Trigger etc.
In the function heading, declare both arrays as constant arrays.
Step 5)
Create a function that determines the one monkey who ate the least amount of food. Output the results in that function using the following format:
Least amount of food: _Monkey # _ ate ____ pounds on Day # _____
In the function heading, declare both arrays as a constant arrays.
*placing the monkey name in the output above.
Step 6)
Create a function that determines the one monkey who ate the most amount of food. Output the results in that function using the following format:
Most amount of food: _Monkey # __ ate ____ pounds on Day # _____
In the function heading, declare both arrays as a constant arrays.
*placing the monkey name in the output above.
Notes:
Use my test data and formatting as suggested above.
Only document the functions.
Use variables and function names that are clear and self-explanatory.
Pass the arrays as constants where appropriate.
Use good spacing in both the code and the output.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started