Question
C++ Programming : Dog Years While it is common to use the formulate 7 dog years for every 1 human year, this is actually inaccurate
C++ Programming: Dog Years
While it is common to use the formulate 7 dog years for every 1 human year, this is actually inaccurate because studies show that larger dogs age more quickly and have shorter life spans than smaller dogs.
Small dogs age:
15 years for the first human year
8 years for the second human year
5 years for the third human year
4 years for each human year above 3
Medium dogs age:
14 years for the first human year
9 years for the second human year
7 years for the third human year
5 years for each human year above 3
Large dogs age:
12 years for the first human year
9 years for the second human year
8 years for the third human year
7 years for each human year above 3
Your job is to write a program that will create an array of structures that will hold dog information for 6 different dogs. You will ask the user to enter in a file name, open the file and read in the dogs name, how much the dog weighs, and how old the dog is in human years. You will pass the array of structures to a function called calc() that will calculate whether the dog is small (20 pounds or less), medium (21 to 50 pounds) or large (greater than 50 pounds) and based on its weight, determine how old the dog is in dog years (perhaps a couple of ifelse if statements). This information will need to be stored in the structure as well. The structure is returned to main( ) and then needs to be passed to a function called sort( ), which asks the user if they wish to sort by name or by size. Complete the sort based on the users answer. Send back the array to main, which then calls the display( ) function, which will print out the dogs name, the size of the dog (NOT weight, but Small, Medium, or Large), its age in human years and its age in dog years. .
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