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 function that accepts an int array

The task calls for: Write a function that accepts an int array and the array's size as arguments. The function should create a copy of the array, except that the element values should be reversed in the copy. The function should return a pointer t..

  Prompts the user to enter an integer

Write the code that prompts the user to enter an integer between 1 and 20 (including 1 and 20), reads the value using cin, and then prints the value that they entered in a statement that begins with "You entered a ". Save this version in a separate l..

  T computes and posters the probabilities of two people

Write a C program that computes and posters the probabilities of two people in a group who are born in the same day. The probability of two people being born in the same day of the year, for a group of  n people, is given by the following formula:

  Write a program that declares three one dimensional

Write a program that declares three one dimensional arrays named miles, gallons, and mpg . Each array should be declared in main( ) and should be capable of holding ten double

  Create a serial object s

The function call operator is overloaded and will generate a sequential integer each time the operator is used and the object can be created with the sequence start value specified.

  If else statements

Define some everyday if else statements you use to determine action. What are the branches of your statement?

  Find maximum velocity and maximum acceleration

Find maximum velocity and maximum acceleration - Write a general function that can be used to find the maximum of any array. Call this function twice in order to find maximum velocity and maximum acceleration.

  Write a program in c of fibonacci series

Write a program in c of fibonaci series with and without using fibo func, both

  Write a program to crypt its input accordingly

Write a program to crypt its input according to a specified transformation scheme

  Function that returns the height of a binary tree

Write a function called getHeight() that returns the height of a given binary tree - CptS 122 Write a function called countSmallerThan() that returns the number of nodes whose values are smaller than the supplied input paramter

  Write a c program that declares an array alpha of 50

write a c program that declares an array alpha of 50 components of the type double. initialize that array so that the

  Emulates the behavior of a bus

Write a program that emulates the behavior of a bus. The bus must have a schedule ( a finite number of times for it to stop) and a certain capacity (number of passengers). In this program the bus has two states: stopped and going.

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