
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question

Transcribed Image Text:Add a boolean instance variable that monitors if the engine is on or off.
Add a boolean instance variable that monitors if the plane is landed.
Create new methods:
o public void startEngine ( ) set the boolean variable to the appropriate
value and print a message
Example:
Delta 747 2021
engine started.
o public void landAndstopEngine () set the boolean variables to the
appropriate value and print a message.
Еxample:
Delta 747 2021
was landed and stopped.
public boolean isEngineOn ( ) return true if the engine is on, returns
false otherwise.
• Modify existing methods with a warning message if the plane is, or is not, running and do
not perform the requested action when appropriate. For example, the plane engine must
be running to fly. The plane must be landed and turned off to add fuel, or check for
inspection.
Examples:
Delta 747 2021 must be ON to fly.
1.
2.
Delta 747 2021 must be landed and OFF to add fuel.
More Methods - continuation
private double calcRange ()
calculate the total range (maximum hours to fly)
based on the fuel in the tank and the gallons per hour of the plane.
private double calcGasNeededToFillTank () - calculate the fuel needed to
fill the tank.
public void simulateMultiCityTrip (int numberCities ) - Use a loop
to simulate a plane flying to a number of cities, entered as input parameter. You must
invoke the fly and addGas methods.
Inside of the loop you need to do the following:
invoke the calcRange () method to figure out the maximum hours you can fly with the
fuel that you have in the tank
generate an integer random number to simulate the number of hours needed to fly to get
to the next city. This random number should be an integer number between 1 and the

Transcribed Image Text:maximum hours (inclusive). Make sure to cast the maximum range to an int before using
it as parameter
invoke the method to start the engine
invoke the fly method and use as the input parameter the random number generated on
the previous step
invoke the method to land the plane and stop the engine
invoke the addGas method. Invoke the calcGasNeededToFillTank () method to
figure out the fuel needed to fill the tank and pass this value as input parameter to the
addGas method.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 7 images

Knowledge Booster
Similar questions
- Look through the method header below, then, as an example, write a call to the method. an internal void ShowValue()arrow_forwardQUESTION 10 Multiple Choice: What is the return type of the following method? public static void widget(double a, String b){ ... } String void int double QUESTION 11 Multiple Choice: Which statement is true about the method below? public static String doStuff(int x, double n, boolean b){ ... } String is the return type of this method int x, doublen, and boolean b will cause a syntax error and should be moved to the method body public and static are identifiers for the method O doStuff is a modifier for the method QUESTION 12arrow_forwardIN PYTHON PLEASE, THANK YOU!!!arrow_forward
- Write a python code for both 1 and 2 use random inputs for each variablearrow_forwardpublic class Accumulator { private int total private String name; public Accummulator (string name , int total) { this .name = name; this .total=total; } } 3. In a main method, create an object of Accumulator with the name as "Mary" and total as 100.arrow_forwarda. Plan the logic for an insurance company program to determine policy premiums. The program continuously prompts the user for an insurance policy number. When the user enters an appropriate sentinel value, end the program. Call a method that prompts each user for the type of policy needed—health or auto. While the user’s response does not indicate health or auto, continue to prompt the user. When the value is valid, return it from the method. Pass the user’s response to a new method where the premium is set and returned—$550 for a health policy or $225 for an auto policy. Display the results for each policy. b.Modify Exercise 9a so that the premium-setting method calls one of two additional methods—one that determines the health premium or one that determines the auto premium. The health insurance method asks users whether they smoke; the premium is $550 for smokers and $345 for nonsmokers. The auto insurance method asks users to enter the number of traffic tickets they have received…arrow_forward
- class Bug { private final int orgPosition = 0; private int currentPosition; private boolean direction; public Bug() { direction = true; currentPosition = orgPosition; } public void move() { if (direction) { ++currentPosition; } else { --currentPosition; } } public void turn() { direction = !direction; } public int getPosition() { return currentPosition; } public boolean getDirection() { return direction; } public String toString() { StringBuffer sb = new StringBuffer(); sb.append("Position = " + currentPosition + ", Direction = "); sb.append(direction ? "RIGHT" : "LEFT"); return sb.toString(); } } -------------------------------------TestDriver.java------------------------------------- import java.util.Scanner; class TestDriver { public static void main(String args[]) { Scanner input = new Scanner(System.in); Bug b…arrow_forward3arrow_forwardAlert dont submit AI generated answer. in Java.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY