Please find the code below:::::
#include <iostream>
#include <string>
using namespace std;
class Planet{
private:
string name;
float percentO2;
int temp;
public:
Planet(){
name="";
percentO2 = 0;
temp = 0;
}
Planet(string n,float p,int t){
name=n;
percentO2 = p;
temp = t;
}
string getName() const
{
return name;
}
float getPercentO2() const
{
return percentO2;
}
int getTemp() const
{
return temp;
}
void setName(string name)
{
this->name = name;
}
void setPercentO2(float percentO2)
{
this->percentO2 =
percentO2;
}
void setTemp(int temp)
{
this->temp = temp;
}
void display(){
cout<<"Name of the Planet :
"<<name<<endl;
cout<<"Percent of O2 of the
Planet : "<<percentO2<<endl;
cout<<"Temperature of the
Planet : "<<temp<<endl;
}
};
int main(){
Planet p;
Planet p2("Earth",68.32,24);
cout<<"Printing Planet p : "<<endl;
p.display();
cout<<endl;
cout<<"Printing Planet p2 : "<<endl;
p2.display();
cout<<"\nSetting value to Planet
P"<<endl;
p.setPercentO2(99.99);
p.setName("Mars");
p.setTemp(120);
p.display();
return 0;
}
output:
![阻 ain.cppConsole <terminated> CPP_Workspace.exe [C/C++ Application] C\Users Mohamm th: printing Planet p: Name of the Planet](http://img.homeworklib.com/questions/0b1cb250-d0ef-11ea-b8d0-1739b090243b.png?x-oss-process=image/resize,w_560)
Create a class called planet with private members name, percent02, temp. Create a constructor prototype and...
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. 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...
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...
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 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...
C++ program Create a Student class that contains three private data members of stududentID (int), lastName (string), firstName(string) and a static data member studentCount(int). Create a constructor that will take three parameters of studentID, lastName and firstName, and assign them to the private data member. Then, increase the studentCount in the constructor. Create a static function getStudentCount() that returns the value of studentCount. studentCount is used to track the number of student object has been instantiated. Initialize it to 0...
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 100 accounts. Use an array of pointers to objects for this. However, your...
PYTHON Task 1 Create a class called Window It has 2 public properties 1 private property 1 constructor that takes 3 arguments pass each argument to the appropriate property Task 2 In a new file import the Window class Instantiate the Window object Output the two public properties Task 3 Alter the Window class in Task 1 Add an accessor and mutator (the ability to access and change) to the private property Task 4 Create a class named Instrument Give...
c++ program Implement a class called Person with the following members: 1a. ????, a private variable of type ?????? 1b. ???, a private variable of type ??? 1c. Default constructor to set name to "" and age to 0 1d. Non-default constructor which accepts two parameters for name and age 1e. A copy constructor 1f. The post-increment operator 1g. The pre-decrement operator 1h. The insertion and extraction stream operators >>and <<
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.
in JAVA Which of the following attributes would be MOST appropriate for a class called Book, that represents a book in a library? libraryName, location, libraryHours title, author, typeOfBook pages, cost, shipping anything, anytime, anywhere Which of the following statements is FALSE regarding constructors? A constructor allows you to set up an object once it is instantiated. A constructor does not have a return type. A constructor must have the same name as the name of the class. You can...