Question: This is a question for my assignment, please respond with the correct code as soon as you can. To be done on Java. Will upvote

This is a question for my assignment, please respond with the correct code as soon as you can. To be done on Java. Will upvote definitely, thanks!

PART A

/** A automobile has a fuel level and an efficiency

P3.7.

Modify the given class Automobile so that it has the following properties. An automobile has a certain fuel efficiency (measured in km/liters) and a certain amount of fuel in the gas tank. The efficiency is initialized in the constructor method via the parameter, and the initial fuel level is 0. Supply a method called drive that simulates driving the automobile for a certain distance, reducing the amount of gasoline in the fuel tank. Also supply methods getGasInTank, returning the current amount of gasoline in the fuel tank, and addGas, to add gasoline to the fuel tank. Look at the tester code (AutomobileTester.java) for help in understanding these methods */ public class Automobile { private double efficiency ; // kilometers per liter private double fuel ; // amount of gas in the tank /** Initialize inastance variables zero fuel and the given efficiency kmPerLiter @param kmPerLiter */ public Automobile(double kmPerLiter) { //-----------Start below here. To do: approximate lines of code = 2 // set the instance variable fuel to zero; //2. set efficiency to the parameter value //-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions. }

/** Drives the automobile the given distance @param distance */ public void drive(double distance) { //-----------Start below here. To do: approximate lines of code = 2 // 1. calculate the gas used in going that distance // i.e. divide distance by efficiency, update fuel accordingly //2. update the fuel instance variable (fule should decrease) //-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions. }

/** Puts fuel in the automobile. @param amount the amount of gas added */ public void addGas(double amount) { //-----------Start below here. To do: approximate lines of code = 1 // update the fuel variable //-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions. }

/** Gets the current fuel level of the automobile. @return the current fuel level */ public double getGasInTank() { //-----------Start below here. To do: approximate lines of code = 1 // return the current fuel level //-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions. } }

PART B

/** This class models a tally counter. */ public class Counter { private int value; private int max;

public void setLimit(int maximum) { max = maximum; }

/** Gets the current value of this counter. @return the current value */ public int getValue() { return value; }

/** Advances the value of this counter by 1. */ public void count() { //-----------Start below here. To do: approximate lines of code = 4 // increments value by 1. if value exceeds limit, print "Limit Exceeded" and reset value to 0 //-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions. }

/** Resets the value of this counter to 0. */ public void reset() { value = 0; } }

PART C

/** A class for representing a microwave oven. */ public class Microwave { int timer; String power; //HIGH or LOW /** Creates a microwave with 0 seconds on the timer and at LOW power. */ public Microwave() { //-----------Start below here. To do: approximate lines of code = 2 // Complete this constructor to initialize instance variables //-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions. } /** Increases the time on the timer by 30 seconds. */ public void increaseTime() { //-----------Start below here. To do: approximate lines of code = 1 // complete the method //-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions. } /** Switches the power level from LOW to HIGH, or vice versa. */ public void switchPower() { //-----------Start below here. To do: approximate lines of code = 4 // Complete this method. //-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions. } /** Resets the microwave to its initial state. */ public void reset() { //-----------Start below here. To do: approximate lines of code = 2 // Complete this method. //-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions. } public void start() { System.out.println("Cooking for " + timer + " seconds at power " + power); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To provide a detailed and correct answer lets address each part sequentially Part A Automobile Class The Automobile class requires several functionalities including initialization and manipulation of ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!