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

Hi, I need help with this program, I cannot seem to get it. There is a data file

ID: 3799320 • Letter: H

Question

Hi, I need help with this program, I cannot seem to get it.


There is a data file called monkeyfood.txt that contains a series of floating-point numbers separated by whitespace. You are welcome to make a copy of it, modify the copy for testing purposes, download it to your local computer, etc.

Program

For this assignment, you will need to write a header and source file for a class called Monkey.

You should define two symbolic constants inside the Monkey.h header file but before the class declaration:

Use them in all of your methods, rather than hardcoding values. We want our program to continue working if we eventually get more monkeys, or we want to track a different number of days.

The Monkey class which will contain the following private data members:

An array of C++ strings containing the names of the monkeys, initialized to "Curious George", "Mojo" and "Marcel".

A two dimensional NUMMONKEYS by NUMDAYS array of float variables that will hold the number of pounds of food each monkey ate each day.

Your class must contain the following public methods:

Monkey()

The constructor takes no parameters and returns nothing. It will read the contents of the file monkeyfood.txt and store each float value into the two dimensional array.

getName()

This method takes an integer index as its parameter and returns a C++ string. This method will return the name of the monkey at the specified index in the monkey names array.

printArray()

This method takes no parameters and returns nothing. It will print a report similar to the following:

totalFoodEaten()

This method takes no parameters, and returns a float, the total pounds of food consumed for all of the monkeys for the week.

avgDailyConsumption()

This method takes no parameters, and returns a float, the average consumption for all of the monkeys for the week. (Hint, you can use totalFoodEaten() in this function. Divide by the number of monkeys * the number of days. Do not hardcode 21!)

avgDailyPerMonkey()

This method takes one parameter, an integer representing the monkey for whom we want to calculate the 7 day food average. The method returns a float which is the average food consumption for that monkey.

mostEaten()

This method takes no parameters and returns nothing. This method will go through the array and find the greatest amount of food eaten during the week by any one monkey on any one day and print the name of the monkey and the greatest amount eaten.

Program Output

Driver Program

A driver program, assign3.cpp, is provided for this assignment. The purpose of a driver program is to test other pieces that you code. You do not need to write the driver program yourself. A copy of the driver program can also be found on turing at /home/turing/t90kjm1/CS241/Code/Spring2017/Assign3/assign3.cpp.

Implementation Hints

The driver program should not be modified for your final submission. But while you're developing, modifying the driver program can definitely be in your best interest. For example, you may want to comment out various parts of main and develop one method at a time.

Makefile

A makefile is required for this assignment, and all future 241 assignments. A sample makefile is given below.

Explanation / Answer

#include #include #include "Monkey.h" using std::cout; using std::endl; using std::left; int main() { Monkey m; int i; //subscript // Print the names of all the monkeys cout
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