Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I tired run this small code but ending up the errors I went the code and didn't find any problem. Please help the finding bug

I tired run this small code but ending up the errors I went the code and didn't find any problem. Please help the finding bug and fix the error

public class Lesson8 {

public static void main(String[] args) {

aircraft cessna172 = new aircraft(); // creates object of class aircraft

aircraft piperSaratoga = new aircraft();

cessna172.passengers = 4;

cessna172.cruiseSpeed = 140;

cessna172.fuelCapacity = 56.5;

cessna172.fuelBurnRate = 9.5;

piperSaratoga.passengers = 6;

piperSaratoga.cruiseSpeed = 201;

piperSaratoga.fuelCapacity = 102.5;

piperSaratoga.fuelBurnRate = 20.5;

System.out.println("Cessna 172 Endurance is: " + cessna172.calulateEndurance());

double enduranceSaratoga = piperSaratoga.calulateEndurance();

System.out.println(" Piper Saratogs Endurance is: " + enduranceSaratoga);

}

}

class aircraft {

int passengers; // number of people

int cruiseSpeed; // miles per hour

double fuelCapacity; // gallons

double fuelBurnRate; // gallons per hour

//Method to calculate aircraft endurance

double calulateEndurance() {

double endurance;

endurance = fuelCapacity / fuelBurnRate;

return endurance;

}

}

image text in transcribed

public class Lesson8 { public static void main(String[] args) { aircraft cessna 172 = new aircraft(); // creates object of class aircraft aircraft piperSaratoga = new aircraft(); Cessna 172. passengers = 4; cessna 172.cruiseSpeed = 140; cessna 172. fuelCapacity = 56.5; cessna 172. fuelBurnRate = 9.5; piperSaratoga. passengers = 6; piperSaratoga.cruiseSpeed = 2017 piperSaratoga. fuelCapacity = 102.5; piperSaratoga. fue lBurnRate = 20.5; System.out.println("Cessna 172 Endurance is: " + cessna172.calulateEndurance()); double enduranceSaratoga = piperSaratoga.calulateEndurance(); System.out.println(" Piper Saratogs Endurance is: " + enduranceSaratoga); 33 234 35 X36 class aircraft { int passengers; int cruise Speed; double fuelCapacity; double fuelBurnRate; // number of people // miles per hour // gallons // gallons per hour 37 38 //Method to calculate aircraft endurance 42 double calulateEndurance() { double endurance; endurance = fuelCapacity / fuelBurnRate; return endurance

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions