Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ Part 1 Part 2 Part 3 Write a program for a user to track the number of miles a person walks each day for
C++
Part 1
Part 2
Part 3
Write a program for a user to track the number of miles a person walks each day for 5 days. The program will have an object of class HealthMeter. - All data members of the meter are private. - HealthMeter has a constructor that takes one parameter: name of the person. It also initializes all the variables of the class. - HealthMeter has function logWalk. It is used to log the miles for a day and will keep track of the total miles walked and the number of days walked. - HealthMeter will also track the miles walked on the first day and last day. - HealthMeter also has at least these two functions: string getName () : returns name of person void getWalkInfo (int\& totalMileage, int\& daysWalked, double\& avgWalkDist, int\& firstWalk, int\& lastWalk) The input will be done in the main program. It will first get the person's name, then loop 4 times and prompt for the mileage walked. After each input, it will call logWalk()log the walk. The range of the input is NOT checked in main. The logWalk() function will check that the daily values are >=0 and Test your program with valid and invalid entries for the 5 days. After the fifth entry, main will call the following functions and neatly print the results: string getName () : returns name of person void getWalkInfo (int\& totalMileage, int\& daysWalked, double\& avgWalkDist, int\& firstWalk, int\& lastWalk) Test you program with the following input sequences plus any other you believe are necessary. Note each line below is a separate run (test case) Cassie 3, 6, 7,9 Anon 0,2,5,0 Mike 3,12,3,6,1 Redo program 2 using try/catch/throw instead of assert, using multiple catches [negative, tooLarge, maybe others?] Display a message when there is invalid input and have the user reenter numbers until 4 walks are recorded. Create an independent function (not a class member function) walkMonitor that is a friend to HealthMeter. When called, walkMonitor is passed a HealthMeter object as a parameter and prints the following information for the object: Monitoring for: >, Mileage: , Days walked: Modify Main to create to have two instances of the HealthMeter class. One for a person named Cassie, the other for Zhoul. Load them with 5 legal values of your choice from main. (You can prompt for the values or write code to load them, - your choice.) For each object, call walkMonitor before any walks are done, after the 2 nd walk is loaded, and final time after the last walk is loaded. You do not need to test for invalid data, you only need to show the friend function is working properly. Provide screen shots of the program output. Write a program for a user to track the number of miles a person walks each day for 5 days. The program will have an object of class HealthMeter. - All data members of the meter are private. - HealthMeter has a constructor that takes one parameter: name of the person. It also initializes all the variables of the class. - HealthMeter has function logWalk. It is used to log the miles for a day and will keep track of the total miles walked and the number of days walked. - HealthMeter will also track the miles walked on the first day and last day. - HealthMeter also has at least these two functions: string getName () : returns name of person void getWalkInfo (int\& totalMileage, int\& daysWalked, double\& avgWalkDist, int\& firstWalk, int\& lastWalk) The input will be done in the main program. It will first get the person's name, then loop 4 times and prompt for the mileage walked. After each input, it will call logWalk()log the walk. The range of the input is NOT checked in main. The logWalk() function will check that the daily values are >=0 and Test your program with valid and invalid entries for the 5 days. After the fifth entry, main will call the following functions and neatly print the results: string getName () : returns name of person void getWalkInfo (int\& totalMileage, int\& daysWalked, double\& avgWalkDist, int\& firstWalk, int\& lastWalk) Test you program with the following input sequences plus any other you believe are necessary. Note each line below is a separate run (test case) Cassie 3, 6, 7,9 Anon 0,2,5,0 Mike 3,12,3,6,1 Redo program 2 using try/catch/throw instead of assert, using multiple catches [negative, tooLarge, maybe others?] Display a message when there is invalid input and have the user reenter numbers until 4 walks are recorded. Create an independent function (not a class member function) walkMonitor that is a friend to HealthMeter. When called, walkMonitor is passed a HealthMeter object as a parameter and prints the following information for the object: Monitoring for: >, Mileage: , Days walked: Modify Main to create to have two instances of the HealthMeter class. One for a person named Cassie, the other for Zhoul. Load them with 5 legal values of your choice from main. (You can prompt for the values or write code to load them, - your choice.) For each object, call walkMonitor before any walks are done, after the 2 nd walk is loaded, and final time after the last walk is loaded. You do not need to test for invalid data, you only need to show the friend function is working properly. Provide screen shots of the program 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