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

  Prompt the user to input the elapsed time for an event

Write a C++ program that prompts the user to input the elapsed time for an event in seconds.

  Analyze the duties performed by operational team

Operational management means the people who will take care of quality of the products, distribution, and inventory. They have to try for increase the sales.

  Implementations of the adt bag

Compare the array-based and link-based implementations of the ADT bag operation remove(anEntry). Suppose the different locations of anEntry within the array or chain.

  Write a java program that reads a set of integer lattice

Write a java program that reads a set of integer lattice points, prints out the ones on the boundry of the convex hull sorted left to right.

  Represent a single playing card from a deck of cards

Write a class Card whose instances represent a single playing card from a deck of cards.

  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.

  Determine obstacles for an organization

There are four (4) critical success factors that are important for effective risk management: supportive organization; competent people; appropriate methods.

  Write a program to simulate the number of picks needed

The problem is to pick objects from a set of objects repeatedly and find out how many picks are needed for all the objects to be picked at least once.

  What is the order of the permutation group

A substitution block has 10 inputs and 10 outputs. What is the order of the permutation group? What is the key size?

  Create some xhtml notes by listing the tags and attributes

On a separate sheet of paper create some XHTML notes by listing the tags and attributes related to tables found on your sample page.

  Find and display the account balances

This assessment item is designed to test your understanding of arrays/arraylists, objects, classes, methods,sorting and searching.

  Design a circuit to perform the arbitration process

A multiprocessor system has three processors, each of which can request the bus at any time asynchronously. Each processor has a bus request output, BR,*.

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