Write a base class named dairyanimal

Assignment Help C/C++ Programming
Reference no: EM13810344

Write a base class named DairyAnimal and two classes, Goat and Cow that inherit from it. You may use one file, or a multi-file project; whichever is easier for you.

1. Declare a DairyAnimal class a. Write a base class named DairyAnimal that has the following data members:

                float age;            //  years             int weight;          // weight of animal in pounds  int food;               // food eaten each day in pounds

b. And the following functions:

DairyAnimal();                                  // set age to 1.0F, weight to 1000, and food to 0 DiaryAnimal(float a, int w);                // overloaded constructor lets you set age and weight void feed(int f);                                 // pounds of food fed to the animal per day float milk();                                        // gallons of milk produced per day =  weight / food

c. Write two tests:  1) Display the amount of milk produced per day using an object created with the default constructor and 20 pounds of food.  2) Display the milk produced using an object created with the overloaded constructor and with age = 1, weight = 100 and lbsFood = 2.

2. Use inheritance to declare a Cow class

a. Override the milk function to use the following calculations:?If the age is 1 or more and 10 or less, gallons of milk = 0.5 * weight / food?Otherwise, gallons of milk = 0

d. Write tests for a: 1) 0.9 year old cow (any weight and amount of food. 2) 1 year old, 900 pound cow which is fed 15 pounds of food. 3) A 10 year old, 1100 pound cow, fed 25 pounds. 4) 10.1 year old cow (any weight and amount of food).

3. Use inheritance to declare a Goat class

a. This class will use DairyAnimal as a base class and inherit the public functions. Decide whether or not you will need to write new constructors.

b. Override the milk function to use the following calculations:?If the age is 0.7 or more and 10 or less, gallons of milk = weight / food?Otherwise, gallons of milk = 0.

Can you call the base class milk function?

c. Write the same four tests as for the Cow class, but use the following weights and amounts of food:

2) weight = 90 pounds, food = 1 pound

3) weight = 110 pounds, food = 2 pounds.

Reference no: EM13810344

Questions Cloud

Situation facing mensa at the time of the case : Describe the situation facing Mensa at the time of the case. This should include the major issues facing the company and the decisions that need to be made.
Statement regarding executive stock-lower risk free rates : Lower risk free rates results in __________ Put Option prices and ______ Call Option Prices. Which statement regarding executive stock options is correct?
Best strategic planning and implementation : Explain the BEST strategic planning and implementation/execution you have observed. Discuss fully. (2) Explain the WORST strategic planning and implementation/execution you have observed. What would you have done differently? Be specific. NOTE: Do..
Scope of project on upgrading office center : Define the scope of the project on upgrading a office center in which you have 7 months to complete include the project goals and objectives, deliverables, tasks, costs, deadlines, and expected main staffing and non-staffing resources needed.
Write a base class named dairyanimal : Write a base class named DairyAnimal and two classes, Goat and Cow that inherit from it. You may use one file, or a multi-file project; whichever is easier for you
Achieving innovation in project-based firms : Which of the approaches for achieving innovation in project-based firms is the most viable across the greatest variety of scenarios? Why? The approaches are the Linear-rational approach, and the Organic approach.
Setting the price on a new outpatient service : Assume that managers of Fort Winston Hospital are setting the price on a new outpatient service. Here are the relevant data estimates: Variable cost per visit $5.00 Annual direct fixed costs $500,000 Annual overhead allocation $50,000 Expected annual..
Create two function for converting between units of distance : It's often necessary to convert between units. In this exercise, you will create two functions for converting between units of distance. The first function will be called ConvertMilesToKilometers(), which will accept one parameter for the number o..
Safety and occupational health professional : You are the safety and occupational health professional for your city's Health Department. You received a call from a major food distribution warehouse that some employees are complaining of dizziness and feeling sick.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a program that prompts the user to input

One metric ton is approximately 2205 pounds. Write a program that prompts the user to input the amount of rice, in pounds, in a bag. The program outputs the number of bags needed to store one.

  Documenting the testing of c program

Writing a test plan and writing a C program with reasonable comments and sensible variable names - Test and documenting the testing of your c program

  Problem related to permutation

Write a recursively function that generates all the permutations of a set of numbers. Use the STL set class for all set operations and the STL linked list class to store and manipulate each individual permutation. When creating a set containing li..

  Reduce the numerator and denominator

Write the function  in C ++ to reduce the numerator and denominator in the Rat class to lowest terms.

  Write an algorithm to compute the volume of water

Write an algorithm to compute the volume of water in cubic feet, flowing through a pipe of diameter d in feet, with a velocity of v feet per second.

  It should be clear, based on your comments

Add comments to the code. It should be clear, based on your comments, what each line (or set of lines) does in the program.

  A palindrome is a number

A palindrome is a number or text phrase that reads the same backward as forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 34543 and 11611. Write a program that reads in a five-digit integer and determines ..

  Program to declare array alpha of components of type int

Write C++ statements to do the following: Declare an array alpha of 15 components of the type int. Output the value of the tenth component of the array alpha.

  Write a program that prompts for and gets a student name

Write a program that gets 10 numbers and stores then in an array. Then sort (low to high) the number using a function.

  Add a sentinel command to stop the loop

add a sentinel command to stop the loop. When the program is compiled, It'll ask the user to type in a palindrome. I want the user to type EXIT to end the loop.

  Program of a class date which displays the date

Write a C++ program of a Class Date which displays the date. Use the subsequent requirements:

  Two-dimensional array to compute the polar coordinates

Write a C program that will read from the input file the time, the x-coordinate, and the y-coordinate values into a two-dimensional array. The program will use the two-dimensional array to compute the polar coordinates.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd