Question
please HELP!! I have been trying to get help for this problem forever!
Create a class called planet with private members name, percent02, temp. Create a constructor prototype and implementation. I
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>
#include<string>

using namespace std;

class Planet
{
private: string name;
private:double percent02;
private: int temp;

public:Planet()
{
name="ABC";
percent02=60.34;
temp=34;
}
public: Planet(string name1,double percent,int temp1 )
{
setName(name1);
setPercent(percent);
setTemp(temp1);
}

public:void setName(string name1)
{
name=name1;
}
public:void setPercent(double percent)
{
percent02=percent;
}
public:void setTemp(int temp1)
{
temp=temp1;
}

public:void display()
{
cout<<"Name : "<<name<<endl;
cout<<"Percent02 : "<<percent02<<endl;
cout<<"Temp : "<<temp<<endl;
}
};

int main()
{
string name1;
double percent;
int temp1;

Planet p1;
p1.display();


cout<<endl<<"Enter new entries : "<<endl<<endl;
cout<<"Enter name : ";
cin>>name1;
cout<<"Enter Percent : ";
cin>>percent;
cout<<"Enter temp : ";
cin>>temp1;

Planet p2(name1,percent,temp1);
cout<<"\n\nNew enteries are : "<<endl<<endl;
p2.display();

system("pause");

return 0;
}

oDebugiPlanet usenDeskt Name ABC Percent02: 60.34 Temp34 Enter new entries Enter name XYZ Enter Percent 67.89 Enter temp 70 N

Add a comment
Know the answer?
Add Answer to:
please HELP!! I have been trying to get help for this problem forever! Create a class...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a class called planet with private members name, percent02, temp. Create a constructor prototype and...

    Create a class called planet with private members name, percent02, temp. Create a constructor prototype and implementation. In the main, create 2 objects of class planet, one with arguments and the other without. Create a function to change name, percent02 and temp after the object has been created and a function that displays the current values of the members. Implement the operations specified above in the main of your program. This is all in C++, please help.

  • Create a class calc with two data members (num1 & num2). The class should have a...

    Create a class calc with two data members (num1 & num2). The class should have a constructor that receives arguments during object creation and sets the values of the members. The class should also have a function called divide() that divides the two numbers and returns the result. The function should throw an exception if the denominator is 0. Create two objects of the class in the main() function. Use class templates making the first object an int and the...

  • Create a C++ project with 2 classes, Person and Birthdate. The description for each class is...

    Create a C++ project with 2 classes, Person and Birthdate. The description for each class is shown below: Birthdate class: private members: year, month and day public members: copy constructor, 3 arguments constructor, destructor, setters, getters and age (this function should return the age) Person class: private members: firstName, lastName, dateOfBirth, SSN public members: 4 arguments constructor (firstName, lastName, datOfBirth and SNN), destructor and printout Implementation: - use the separated files approach - implement all the methods for the 2...

  • Need some help with this C++ code. Please screenshot the code if possible. Purpose: Demonstrate the...

    Need some help with this C++ code. Please screenshot the code if possible. Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment also aims at creating a C++ project to handle multiple files (one header file and two .cpp files) at the same time. Remember to follow documentation and variable name guidelines. Create a C++ project to implement a simplified banking system. Your bank is small, so it can have a maximum of...

  • C++ Assignment: Create a class called FitnessMember that has only one variable, called name. The FitnessMember...

    C++ Assignment: Create a class called FitnessMember that has only one variable, called name. The FitnessMember class should have a constructor with no parameters, a constructor with a parameter, a mutator function and an accessor function. Also, include a function to display the name. Define a class called Athlete which is derived from FitnessMember. An Athlete record has the Athlete's name (defined in the FitnessMember class), ID number of type String and integer number of training days. Define a class...

  • Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   and please put comment with code! Problem:2 1. Class Student Create...

    Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   and please put comment with code! Problem:2 1. Class Student Create a "Hello C++! I love CS52" Program 10 points Create a program that simply outputs the text Hello C++!I love CS52" when you run it. This can be done by using cout object in the main function. 2. Create a Class and an Object In the same file as...

  • Using C++ create a class called person. A person can have a name, address, age. For...

    Using C++ create a class called person. A person can have a name, address, age. For this class create a default constructor and parameterized constructor. Show the main as int main() { } ----------------------------------------------------- Show how you will define the class and call it in the main. Only create two instances/objects in main using the two created constructors.

  • Help with this coding assignment for C++! Add any comments for better understanding. Create a class...

    Help with this coding assignment for C++! Add any comments for better understanding. Create a class named CupCake. It contains: • Has private instance variables 1. egg 2. butter 3. baking powder 4. sugar 5. flour 6. milk • All members must have public methods: getter() and setter(). • A constructor - a default constructor with no arguments. The constructor will initial all member variable to a default value 0. • One public pure virtual function showingredients() that returns void....

  • Create a class hierarchy to be used in a university setting. The classes are as follows:...

    Create a class hierarchy to be used in a university setting. The classes are as follows: The base class is Person. The class should have 3 data members: personID (integer), firstName(string), and lastName(string). The class should also have a static data member called nextID which is used to assign an ID number to each object created (personID). All data members must be private. Create the following member functions: o Accessor functions to allow access to first name and last name...

  • C++ This exercise will introduce static member variables and static methods in class to you. Class...

    C++ This exercise will introduce static member variables and static methods in class to you. Class Department contain information about universities departments: name students amount in addition it also stores information about overall amount of departments at the university: departments amount class Department { public: Department(string i_name, int i_num_students); ~Department(); int get_students(); string get_name(); static int get_total(); private: string name; int num_students; static int total_departments; }; Carefully read and modify the template. You have to implement private static variable "total...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT