Question
In the Contestant class, complete the function definition for SetName() that takes in the string parameter newName. Ex: If the input is 7.5 42 Ralitza,
In the Contestant class, complete the function definition for SetName() that takes in the string parameter newName.
Ex: If the input is 7.5 42 Ralitza, then the output is:
Height: 7.5 Age: 42 Name: Ralitza
#include
class Contestant { public: void SetHeight(double newHeight); void SetAge(int newAge); void SetName(string newName); double GetHeight() const; int GetAge() const; string GetName() const; private: double height; int age; string name; };
void Contestant::SetHeight(double newHeight) { height = newHeight; }
void Contestant::SetAge(int newAge) { age = newAge; }
/* Your code goes here */ { name = newName; }
double Contestant::GetHeight() const { return height; }
int Contestant::GetAge() const { return age; }
string Contestant::GetName() const { return name; }
int main() { Contestant contestant1; double inputHeight; int inputAge; string inputName;
cin >> inputHeight; cin >> inputAge; cin >> inputName;
contestant1.SetHeight(inputHeight); contestant1.SetAge(inputAge); contestant1.SetName(inputName); cout << "Height: " << contestant1.GetHeight() << endl; cout << "Age: " << contestant1.GetAge() << endl; cout << "Name: " << contestant1.GetName() << endl;
return 0; }
c++ and please please make it correct
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