Question

1. An airplane model can be described (highly oversimplified) by the following attributes • model: string...

1. An airplane model can be described (highly oversimplified) by the following attributes • model: string • emptyweight: double • number of seats: int • fuel Consumption: double

a) Define a class AirplaneModel with the attributes defined above.

b) Your class should contain the following member functions: • A default constructor that initializes the class’s attributes.

• A constructor that sets the attributes. • string getName() to get the model’s name

• double getEmptyWeight() to get the model’s empty weight •

int getSeats() to get the number of seats

• double getFuelConsumption() to get the fuel consumption

• setName(string) to set the model’s name •

setEmptyWeight(double) to set the model’s empty weight •

setFuelConsumption(double) to set the fuel consumption •

setSeats(int ): to set the number of seats to an airplane.

• AddSeats(int ): to add seats to an airplane of seats.

c) Write the implementation of the above functions and include them in a C++ file using only iostream library

d) Develop an application that uses the Airplane class and perform the following tasks:

• Construct an object called Boeing737 that is initialized with the following data:

modeltobegiven737

emptyweight:41145Kg

numberofseats:200

fuelConsumption:750gallons/hour

• Construct another object call AirbusA320 and get all its data from the user and then set the values read from the input using the appropriate mutators.

Assume the following values of the Airbus object:

modeltobegivenA320

emptyweight:37230Kg

numberofseats:220

fuelConsumption:1073gallons/hour •

Display a report about the two airplane objects • Add 50 seats to the two airplane objects •

Compute the increased fuel consumption as a result of increasing the number of seats using this equation (fuel Consumption/number of seats)* the new number of seats, for the two objects

• Display the number of seats and the new fuel consumptions of the two the Boeing 737 and the Airbus A320

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

#include<iostream>
using namespace std;
class AirplaneModel
{
   string model;
   double emptyWeight;
   int numberOfSeats;
   double fuelConsumption;
   public:
   AirplaneModel()//default constructor
   {
      
   }
   AirplaneModel(string model, double emptyWeight, int numberOfSeats, double fuelConsumption)//parameterised constructor
   {
       this->model=model;this->emptyWeight=emptyWeight;this->numberOfSeats=numberOfSeats;this->fuelConsumption=fuelConsumption;
   }
   string getName()//get methods
   {
       return model;
   }
   double getEmptyWeight()
   {
       return emptyWeight;
   }
   int getSeats()
   {
       return numberOfSeats;
   }
   double getFuelConsumption()
   {
       return fuelConsumption;
   }
   void setName(string name)//set methods
   {
       model=name;
   }
   void setEmptyWeight(double wt)
   {
       emptyWeight=wt;
   }
   void setFuelConsumption(double fuel)
   {
       fuelConsumption=fuel;
   }
   void setSeats(int sts)
   {
       numberOfSeats=sts;
   }
   void AddSeats(int sts)
   {
       numberOfSeats+=sts;
   }
};
int main()
{
   AirplaneModel Boeing737("737", 41145, 200, 750);//declared
   AirplaneModel AirbusA320;
   AirbusA320.setName("A320");AirbusA320.setEmptyWeight(37230);//setting explicitly
   AirbusA320.setSeats(220);AirbusA320.setFuelConsumption(1073);
   cout<<"Boeing737"<<endl;
   cout<<"No. of seats: "<<Boeing737.getSeats()<<endl;
   cout<<"Model: "<<Boeing737.getName()<<endl;
   cout<<"Fuel consumption: "<<Boeing737.getFuelConsumption()<<endl;
   cout<<"Seats: "<<Boeing737.getSeats()<<endl;
   cout<<"Empty Weight: "<<Boeing737.getEmptyWeight()<<endl;
   cout<<"AirbusA320"<<endl;
   cout<<"No. of seats: "<<AirbusA320.getSeats()<<endl;
   cout<<"Model: "<<AirbusA320.getName()<<endl;
   cout<<"Fuel consumption: "<<AirbusA320.getFuelConsumption()<<endl;
   cout<<"Seats: "<<AirbusA320.getSeats()<<endl;
   cout<<"Empty Weight: "<<AirbusA320.getEmptyWeight()<<endl;
   Boeing737.AddSeats(50);
   AirbusA320.AddSeats(50);
   Boeing737.setFuelConsumption(Boeing737.getSeats()*Boeing737.getFuelConsumption()/(Boeing737.getSeats()-50));//increasing fuel
   AirbusA320.setFuelConsumption(AirbusA320.getSeats()*AirbusA320.getFuelConsumption()/(AirbusA320.getSeats()-50));
   cout<<"Increased fuel consumption of AirbusA320: "<<AirbusA320.getFuelConsumption()<<endl;
   cout<<"Seats: "<<AirbusA320.getSeats()<<endl;
   cout<<"Increased fuel consumption of Boeing737: "<<Boeing737.getFuelConsumption()<<endl;
   cout<<"Seats: "<<Boeing737.getSeats()<<endl;
   return 0;
}

Output:

Add a comment
Know the answer?
Add Answer to:
1. An airplane model can be described (highly oversimplified) by the following attributes • model: string...
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
  • C# programming 50 pts Question 2:2 1- Create the base class Book that has the following instance variables, constructor, and methods title (String) isbn (String) authors (String) publisher (Strin...

    C# programming 50 pts Question 2:2 1- Create the base class Book that has the following instance variables, constructor, and methods title (String) isbn (String) authors (String) publisher (String) edition ( int) published year (int) Constructor that takes all of the above variables as input parameters. set/get methods ToString method// that return sting representation of Book object. 2-Create the sub class New_Book that is derived from the base class Book and has the following instance variables, constructor, and methods: title...

  • Book: - title: String - price: double +Book() +Book(String, double) +getTitle(): String +setTitle(String): void +getPrice(): double...

    Book: - title: String - price: double +Book() +Book(String, double) +getTitle(): String +setTitle(String): void +getPrice(): double +setPrice(double): void +toString(): String The class has two attributes, title and price, and get/set methods for the two attributes. The first constructor doesn’t have a parameter. It assigns “” to title and 0.0 to price; The second constructor uses passed-in parameters to initialize the two attributes. The toString() method returns values for the two attributes. Notation: - means private, and + means public. 1....

  • using CSCI300 java Given the following UML Class Diagram Club_Card # card_num : String # name...

    using CSCI300 java Given the following UML Class Diagram Club_Card # card_num : String # name : String # age: int # year: int + Club_Card (all parameters) + Setters & Getters + toString() : String + equals(x: Object): boolean [10 pts] Define the class Club_Card, which contains: 1. All arguments constructor which accepts all required arguments from the main and instantiate a Club_Card object. 2. Set & get method for each data attribute. 3. A toString() method which returns...

  • In Java Create a class Worker. Your Worker class should include the following attributes as String...

    In Java Create a class Worker. Your Worker class should include the following attributes as String variables: Name, Worker ID, Worker Address, Worker City, Worker State Create the constructor that initializes the above worker attributes. Then make another class name HourlyWorker that inherits from the Worker class.   HourlyWOrker has to use the inherited parent class variables and add in hourlySalary and billableHours. Your HourlyWorker class should contain a constructor that calls the constructor from the Worker class to initialize the...

  • Create an abstract class Employee. Your Employee class should include the following attributes: First name (string)...

    Create an abstract class Employee. Your Employee class should include the following attributes: First name (string) Last name (string) Employee id (string) Employee home street address (string) Employee home city (string) Employee home state (string) Write a constructor to initialize the above Employee attributes. Create an abstract method called earnings.      Create another class HourlyEmployee that inherits from the abstract Employee class.   HourEmployee must use the inherited parent class variables and add in attributes HourlyRate and HoursWorked. Your HourEmployee class should...

  • Create an abstract class Employee. Your Employee class should include the following attributes: First name (string)...

    Create an abstract class Employee. Your Employee class should include the following attributes: First name (string) Last name (string) Employee id (string) Employee home street address (string) Employee home city (string) Employee home state (string) Write a constructor to initialize the above Employee attributes. Create an abstract method called earnings.      Create another class HourlyEmployee that inherits from the abstract Employee class.   HourEmployee must use the inherited parent class variables and add in attributes HourlyRate and HoursWorked. Your HourEmployee class should...

  • Create the Employee class: The Employee class has three attributes: private: string firstName; string lastName; string...

    Create the Employee class: The Employee class has three attributes: private: string firstName; string lastName; string SSN; The Employee class has ▪ a no-arg constructor (a no-arg contructor is a contructor with an empty parameter list): In this no-arg constructor, use “unknown” to initialize all private attributes. ▪ a constructor with parameters for each of the attributes ▪ getter and setter methods for each of the private attributes ▪ a method getFullName() that returns the last name, followed by a...

  • Additional info is this will use a total of four classes Book, BookApp, TextBook, and TextBookApp....

    Additional info is this will use a total of four classes Book, BookApp, TextBook, and TextBookApp. Also uses Super in the TextBook Class section. Problem 1 (10 points) Вook The left side diagram is a UML diagram for Book class. - title: String The class has two attributes, title and price, and get/set methods for the two attributes. - price: double Вook) Book(String, double) getTitle(): String setTitle(String): void + getPrice() double setPrice(double): void toString() String + The first constructor doesn't...

  • Create a class Circle with one instance variable of type double called radius. Then define an...

    Create a class Circle with one instance variable of type double called radius. Then define an appropriate constructor that takes an initial value for the radius, get and set methods for the radius, and methods getArea and getPerimeter. Create a class RightTriangle with three instance variables of type double called base, height, and hypotenuse. Then define an appropriate constructor that takes initial values for the base and height and calculates the hypotenuse, a single set method which takes new values...

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
ADVERTISEMENT