Concept explainers
#include <iostream>
using namespace std;
Class Moon;
{
Private;
double earthWeight;
double moonWeight;
Public;
moonWeight(double ew);
{ earthWeight = ew; moonWeight = earthWeight / 6; }
double getMoonWeight();
{ return moonWeight; }
}
int main()
{
double earth;
cout ≫ "What is your weight?”;
cin ≪ earth;
Moon 1unar(earth);
cout ≪ "On the moon you would weigh "
≪lunar.getMoonWeight() ≪ endl;
return 0;
}
Want to see the full answer?
Check out a sample textbook solutionChapter 13 Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
Additional Engineering Textbook Solutions
Database Concepts (8th Edition)
Starting Out with Programming Logic and Design (4th Edition)
Starting Out with Java: Early Objects (6th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Starting Out with C++: Early Objects (9th Edition)
Database Concepts (7th Edition)
- C++arrow_forwardclass Lease{ private String name; private int aptNumber; private double rent; private int term; private static final int FEE = 10; public Lease(){ name = "XXX"; aptNumber = 0; rent = 1000; term = 12; } public void setName(String tenant) { name = tenant; } public void setAptNumber(int apt){ aptNumber = apt; } public void setRent(double monthRent) { rent = monthRent; } public void setTerm(int t){ term = t; } public String getName(){ return name; } public int getAptNumber(){ return aptNumber; } public double getRent(){ return rent; } public int getTerm(){ return term; } public void addPetFee(){ rent = rent + FEE; } } Create a class named TestLease as instructed below: Instantiate four Lease objects in the main()method. Change the aptNumber value for the first object to 20 Change the rent value…arrow_forwardLOVELY PROFESSIONAL UNIVERSITY Academic Task No. 1 School : of Computer Science and Engineering Name of the faculty member_Ms. Gauri Mathur_ Course Code: CSE202 Faculty of: Technology and Sciences Course Title: Object Oriented Programming Program: Max. Marks: 30 Term: Is Rubric Applicable: No Date of Allotment: 26/02/2021 Date of Submission: 09/03/2021 Important Guidelines: 1. All questions in this Academic Task are compulsory. 2. It is mandatory to attempt all questions of the assignment in your own handwriting on A4 size sheets/pages with a blue colour ink pen. Any other mode of attempt (typed or printed codes or table) except hand written/drawn will not be accepted/considered as valid submission(s) under any circumstances. 3. Every attempted sheet/page should carry clear details of student such as Name, Registration number, Roll number, Question number and Page number. The page numbers should be written clearly on the bottom of every attempted sheet in a prescribed format as: for…arrow_forward
- // volunteer.h #include class Volunteer { public: Volunteer () { } std::string Name () void SetName (const private: std::string name_; }; const { return name_; } std::string& name) { name_ = name; }arrow_forwardQ No 3. #include <string> using namespace std; class Account { public: Account(string accountName, int initialBalance) { name=accountName; if (initialBalance > 0) { balance = initialBalance; } } void deposit(int depositAmount) { if (depositAmount > 0) { balance = balance + depositAmount; } } int getBalance() const { return balance; } void setName(string accountName) { name = accountName; } string getName() const { return name; } private: string name; int balance; }; Rewrite the following code in correct form. a) Assume the following prototype of destructor is declared in class Time: void ~Time(int); b) Assume the following prototype of constructor is declared in class Employee: int Employee(string, string);…arrow_forward#include using namespace std; class Student{ public: Student() { cout<<"Hello"<arrow_forwardstruct ID { int x; int y; }; struct name { ID r; }; int main() { name a[2]; for (int i=0;i<2;i++) { a[i).r.x=i; a[i].r.y=i+1; } for(int i=0;i<2;i++) cout<arrow_forwardpackage application; public class Employee { private int eid; private String name; private String department; private float salary; private String mobileNo; public Employee() { super(); } public Employee(int eid, String name, String department, float salary, String mobileNo) { super(); this.eid = eid; this.name = name; this.department = department; this.salary = salary; this.mobileNo = mobileNo; } public int getEid() { return eid; } public void setEid(int eid) { this.eid = eid; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDepartment() { return department; } public void setDepartment(String department) { this.department = department; } public float getSalary() { return salary; } public void setSalary(float salary) { this.salary = salary; } public String getMobileNo() { return mobileNo; } public void setMobileNo(String mobileNo) { this.mobileNo = mobileNo; } } Is…arrow_forwardclass Player { protected: string name; double weight; double height; public: Player(string n, double w, double h) { name = n; weight = w; height = h; } string getName() const { return name; } virtual void printStats() const = 0; }; class BasketballPlayer : public Player { private: int fieldgoals; int attempts; public: BasketballPlayer(string n, double w, double h, int fg, int a) : Player(n, w, h) { fieldgoals = fg; attempts = a; } void printStats() const { cout << name << endl; cout << "Weight: " << weight; cout << " Height: " << height << endl; cout << "FG: " << fieldgoals; cout << " attempts: " << attempts; cout << " Pct: " << (double) fieldgoals / attempts << endl; } }; a. What does = 0 after function printStats() do? b. Would the following line in main() compile: Player p; -- why or why not? c. Could…arrow_forward#include #include #include #include using namespace std; class AttackInfo{ public: }; int dmg; string description; AttackInfo() AttackInfo(int a, string b){ dmg = a; description = b; class BaseCharacter{ private: } string name; int maxHP,presentHP,dodgeChance; public: int strength, agility,intelligence, baseDamage; public: BaseCharacter() { BaseCharacter(string a, int b, int c, int d, int e, int f, int g){ name = a; strength = b; agility = c; intelligence = d; maxHP = e; presentHP = maxHP; dodgeChance = f; baseDamage=g; } AttackInfo primaryAttack(){ return AttackInfo(baseDamage,"strikes at"); } at"); AttackInfo secondaryAttack(){ return AttackInfo(baseDamage,""); } } void takeDamage(int a){} string toString(){ return "Name: "+getName()+"Max HP: "+to_string(getMaxHp())+" Present HP: "+to_string(getPresentHP())+"Dodge Chance: "+to_string(get DodgeChance()); } }; AttackInfo getAttack(){ return primaryAttack(); }; class Warrior: public BaseCharacter{ private: string getName(){return name;}…arrow_forwardclass Vehicle { private: int wheels; protected : int passenger: public : void inputdata(int, int); void outputdata(); }; class Heavyvehicle : protected Vehicle { int diesel_petrol; protected : int load; public: void readdata(int, int); void writedata(); }; class Bus : private Heavyvehicle char make[20]; public : void fetchdata(char); void displaydata(); (1) Name the base class and derived class of the class Heavyvehicle. (ii) Name the data member(s) that can be accessed from function displaydata(). (iii) Name the data member's that can be accessed by an object of Bus class. (iv) Is the member function outputdata() accessible to the objects of Heavyvehicle class.arrow_forwardC++ Language Activity 5: DERIVED CLASS • Create a SAVING ACCOUNT class that inherits the class BANK ACCOUNT. • Create a constructor for the derived class that accepts INTEREST RATE. • Create a method that displays the INTEREST RATE. • Create a method that computes the INTEREST (BALANCE * INTEREST RATE) and adds to the current BALANCE.arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_iosRecommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSONC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education