Question: 7 . 4 LAB: Lab Rats Write a program that stores the following data about lab rats in a structure named Rat: - The rat's
LAB: Lab Rats Write a program that stores the following data about lab rats in a structure named Rat: The rat's name The rat's weight in ounces The amount of time in seconds it took the rat to run the maze You must use the bolded identifiers above when naming your struct and its members. Also use string, double, and int for the data types. The program should keep an array of of these structures. When the program runs, it should initialize the array using the following data: "Ben", "Fred", "Splinter", "Lima Bean", "Black Bean", "Pinto Bean", "Skat", "Big Bob", Tiger", Each time the program runs, it should prompt the user to enter the time it took each rat to run the maze the rat's name should be given as a prompt These values should be stored in the array. It should then show a table that lists each rat's name, weight, and time. The program should also calculate and display the average weight of all of the rats. Then it should display the name and the time of the rat who ran the maze the fastest. The average weight should be displayed with exactly one digit after the decimal hint: use fixed and setprecision Your program must include two functions, one to calculate the average weight and one to find the fastest rat. These functions should take an array of Rats as an argument. The first one should return the average weight, the second one should return the index of the fastest rat in the array. Use the following function names: averageWeight returns a double fastestRat returns an int These functions should take an array of Rats as an argument. Do not include a parameter for the size. Your program should have one global named constant, for the number of rats The output assuming the user enters for the times is: Ben: Fred : Splinter: Lima Bean: Black Bean: Pinto Bean: Skat: Big Bob: Tiger: DATA: Ben Fred Splinter Lima Bean Black Bean Pinto Bean Skat Big Bob Tiger Average weight: Fastest Rat: Lima Bean Time: Note: you should not echo the input back to the screen.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
