A constructor that accepts a parameter of type double

Assignment Help Computer Engineering
Reference no: EM132197002

Write a class named GasTank containing: An instance variable named amount of type double , initialized to 0.

An instance variable named capacity of type double .

A constructor that accepts a parameter of type double .

The value of the parameter is used to initialize the value of capacity.

A method named addGas that accepts a parameter of type double .

The value of the amount instance variable is increased by the value of the parameter .

However, if the value of amount is increased beyond the value of capacity, amount is set to capacity.

A method named useGas that accepts a parameter of type double .

The value of the amount instance variable is decreased by the value of the parameter .

However, if the value of amount is decreased below 0, amount is set to 0.

A method named isEmpty that accepts no parameters .

isEmpty returns a boolean value : true if the value of amount is less than 0.1, and false otherwise.

A method named isFull that accepts no parameters .

isFull returns a boolean value : true if the value of amount is greater than capacity-0.1, and false otherwise.

A method named getGasLevel that accepts no parameters . getGasLevel returns the value of the amount instance variable.

A method named fillUp that accepts no parameters .

fillUp increases amount to capacity and returns the difference between the value of capacity and the original value of amount (that is, the amount of gas that is needed to fill the tank to capacity). In Java please!

Reference no: EM132197002

Questions Cloud

Write a constructor that accepts arguments for each member : Write a constructor that accepts arguments for each member variable, appropriate mutator functions that store values in these member variables.
Write the code for an applet or gui that has three buttons : Write the code for an applet or GUI that has three buttons labeled Red, White, and Blue.
Write a persuasive and researched essay : Pick an item of technology (your choice); then write a persuasive and researched essay - Is the item of technology good or bad for the United States
Write a class and a java program to use the class : A constructor that receives 2 double parameters; the constructor will use these parameters to initialize the incomeYTD and the hourlyRate respectively.
A constructor that accepts a parameter of type double : Write a class named GasTank containing: An instance variable named amount of type double , initialized to 0.
Write accessor and mutator functions for radius : Write a class declaration named Circle with a private member variable named radius. Write accessor and mutator functions for radius.
Write a client program that connects to the server : Write a client program in C/C++ that connects to the server you wrote in problem.
Discuss an episode of government intervention : BFW2341 International Financial Management - Monash university - Evaluation of government intervention in the foreign exchange market
Write a client class to test all your methods : Write a class encapsulating the concept of a Student, assuming that a student has the following attributes: last name, first name, id, array of grades.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Discuss conduct a risk assessment for an organization

Describe a methodology that can be used to conduct a risk assessment for an organization

  When the server reboots will the file handle still be valid

When the server reboots, will the file handle still be valid? If so, how does it work? If not, does this violate the principle of statelessness?

  Provide a modification of the timed pn model presented

Imagine that some transition of a PN models a process of this type. Provide a modification of the timed PN model presented here that is able to cope with case.

  Produce a simple command processor

Now that the OS has a keyboard driver, it is possible to produce a simple command processor. You should expand the Run() method in command.c to produce a simple command processor that implements the following commands: cls- Clear the screen

  Evaluate the total with insurance

Enter the insurance rate as a mixed cell reference in the formula, making the row number absolute.

  Windows server deployment proposal

Windows Server Deployment Proposal

  Tanslate the below information into six rules

If the headlights are bright (or dim only slightly), the trouble is either in the starter itself, the solenoid, or in the wiring.

  Describe software construction

Describe software construction

  Write a program that allows the user to navigate the lines

If the line number provided by the user is not numeric, program should handle the conversion exception.

  Why did the set timeout

IF i want to conect a raspberry pi 3 with a GSM modum through a serial port , and since the GSM modum is talking at 9600 (by datashet).

  Describe data independence using given information

Describe the 3-level architecture. Discuss the pros and cons of having a separate DA and DBA or the need for 1 person doing it all.

  Compare intelligence and simulated intelligence

Analyse the meanings of intelligence and simulated intelligence. Compare intelligence and simulated intelligence.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd