Create a class named JumboJet. A JumboJet has fields for aircraft model as a Str
ID: 3730306 • Letter: C
Question
Create a class named JumboJet. A JumboJet has fields for aircraft model as a String, number of seats as an Integer, and fuel tank capacity as an Integer. Please include methods to set values to all fields. JumboJet further has a field for fuel efficiency as a double. Please include a method to calculate the fuel efficiency by dividing the fuel tank capacity by the number of seats. Methods to display the values in each JumboJet field are to be included in the class. Also included in the JumboJet class is a constructor. The constructor should initialize each JumboJet's aircraft model to B747, number of seats to 365, and fuel tank capacity to 183380. Save this class as JumboJet.java. Write a program that demonstrates that the constructor works by instantiating an object and displaying the initial values for all fields. Save the application as QueenofJumboJet.java. Please use proper indenting to write program.Explanation / Answer
public class JumboJet {
private String model;
private int seats;
private int fuelCapacity;
private double fuelEfficiency;
// setters
public void setModel(String model) {
this.model = model;
}
public void setSeats(int seats) {
this.seats = seats;
}
public void setFuelCapacity(int fuelCapacity) {
this.fuelCapacity = fuelCapacity;
}
public void calcFuelEfficiency(){
fuelEfficiency = seats/(double)fuelCapacity;
}
public void display() {
System.out.println("Model: "+model);
System.out.println("Number of seats: "+seats);
System.out.println("Fuel capacity: "+fuelCapacity);
System.out.println("Fuel efficiency: "+fuelEfficiency);
}
public JumboJet() {
model = "B747";
seats = 365;
fuelCapacity = 113380;
}
}
####################
public class QueenOfJumboJet {
public static void main(String[] args) {
JumboJet j1 = new JumboJet();
j1.display();
}
}
/*
Sample run:
Model: B747
Number of seats: 365
Fuel capacity: 113380
Fuel efficiency: 0.0
*/
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.