1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Aleonysh [2.5K]
3 years ago
13

Write a class "Dog" with a private int field called months and two public member functions setAge and GetStage. setAge takes as

argument monthsToSet and sets the member field months. setAge returns void. getStage is a const member function that takes no argument and returns a string "Puppy" if the dog is less than 9 months old, "Adolescence" if more than 9 and less than 13 months, "Adulthood" if more than 13 and less than 60 months and "Senior" otherwise. The main should create a Dog called Buddy, set its age to 14 and cout the string returned by GetStage.

Computers and Technology
1 answer:
expeople1 [14]3 years ago
3 0

Answer:

see explaination

Explanation:

#include <iostream>

using namespace std;

class Dog {

int months;

public:

void SetAge(int mnths);

string GetStage() const;

//FIXME: Add declarations of member functions and fields

};

//FIXME: Add definitions of member functions

void Dog::SetAge(int mnths)

{

months = mnths;

}

string Dog::GetStage() const

{

if(months<9)

return string("Puppy");

else if(months<13)

return string("Adolescence");

else if(months<60)

return string("Adulthood");

else

return string("Senior");

}

int main() {

Dog buddy;

buddy.SetAge(14);

cout << buddy.GetStage();

return 0;

}

See attachment for screenshot and output.

You might be interested in
1. Select two forms of case designed suitable for ATX power supply and
jekas [21]
The answer should be c
4 0
2 years ago
Ted is a fashion designer. Where is he most likely to work
vredina [299]
Ted is most likely to work in New York or France
6 0
3 years ago
Information goes into a computer through _______ and comes our through _______
vaieri [72.5K]
Imformation goes into a computer through wires and comes out through data/gigabites. Or when you print it.
5 0
3 years ago
Read 2 more answers
Select the correct answer.
TiliK225 [7]

A group of reviewers with your highest ratings

3 0
3 years ago
A ____ is any key that uniquely identifies each row.
Mrac [35]
<span>A _superkey___ is any key that uniquely identifies each row.</span>
6 0
3 years ago
Other questions:
  • What is the name of the program that takes high-level code and transforms it into machine-level code?
    8·1 answer
  • Markup is best defined as
    11·1 answer
  • Can you clone apps form your PC and to other PC?<br>Yes or No
    13·2 answers
  • It is important to verify internet source because-------- choose that apply. A.the source should be written by real author. B.an
    6·2 answers
  • Drag each tile to the correct box.
    9·1 answer
  • Identify the terms associated with the given statements below;
    6·1 answer
  • Can anyone fill in the space please
    6·1 answer
  • You are a domain administrator for a large domain. Recently, you have been asked to make changes to some of the permissions rela
    11·1 answer
  • Match letters from column B to Column A by looking at the picture above.
    11·1 answer
  • You should always be afraid to use the internet<br><br> True or false?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!