1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Anvisha [2.4K]
4 years ago
13

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).
Computers and Technology
1 answer:
telo118 [61]4 years ago
5 0

Answer:

The class GasTank is defined below

All the steps are briefed in comments

public class GasTank {

// instance variable initialization

private double amount = 0;

//declaring instance variable capacitance

private double capacity;

//constructor having parameter of type double

public GasTank(double i)

{

capacity = i;

}

// addGas method for increasing gas quantity.

public void addGas(double i)

//quantity of gas increased is added to the existing amount. If it becomes more than total capacity, amount is set to capacity

{ amount += i; if(amount > capacity) amount = capacity; / amount = amount < capacity ? amount+i : capacity;/ }

//useGas method having parameter of type double

public void useGas(double i)

//the parameter given is deducted from 0 and if results less than 0, remains equal to 0

{ amount = amount < 0 ? 0 : amount - i; }

//method isEmpty

public boolean isEmpty()

//Returns true if volume is less than 0.1 else false

{ return amount < 0.1 ? true : false; }

//method isFull

public boolean isFull()

//returns true if the value of amount is greater than  0.1 else false.

{ return amount > (capacity-0.1) ? true : false; }

//method getGasLeve

public double getGasLevel()

//Returns the value of amount instance variable

{ return amount; }

//method fillUp

public double fillUp()

//returns the difference between the capacity and the amount

{ double blah = capacity - amount; amount = capacity; return blah; }

}

You might be interested in
Your grandmother was an established artist and left you several original paintings after she died. Which of these statements is
Andreyy89
it's the first one, lasts for life plus 70 years.
7 0
4 years ago
Similarities between incremental and<br> prototyping models of SDLC
Ahat [919]

Prototype Model is a software development life cycle model which is used when the client is not known completely about how the end outcome should be and its requirements.

Incremental Model is a model of software consequence where the product is, analyzed, developed, implemented and tested incrementally until the development is finished.

<h3>What is incremental model in SDLC?</h3>

The incremental Model is a process of software development where conditions are divided into multiple standalone modules of the software development cycle. In this model, each module goes through the conditions, design, implementation and testing phases.

The spiral model is equivalent to the incremental model, with more emphasis placed on risk analysis. The spiral model has four stages: Planning, Risk Analysis, Engineering, and Evaluation. A software project frequently passes through these phases in iterations

To learn more about Prototype Model , refer

brainly.com/question/7509258

#SPJ9

5 0
1 year ago
Why is outfitting a workspace with video games in technology development company considered a strategic use of money
Romashka [77]

They can study what the video game consoles are made up of and how they work so that way the can implement them into their work.

4 0
4 years ago
Read 2 more answers
HELP ASAP. Which of the following is the best example of an installation issue? A computer can’t find the file that it needs to
Svetlanka [38]

Answer:

The question is sufficiently broad that multiple answers would be likely candidates.  I would say though that the most likely "correct" answer is the last one - a program is incompatible with the OS.  That's definitely an issue with installing the wrong package.

Explanation:

With the first answer - A computer can't find the file it needs to perform an OS operation - that's more likely due to file corruption, accidental deletion, or some other event like that.  It could potentially be an issue with installation of the OS, but I doubt that's what's meant.

With the second answer - A computer displays errors and gives you a BSOD - this could be any number of issues, but installation is not the best candidate.

With the third - A user made an error while trying to set up a software - that depends on what they mean by "set up".  If they mean installation, then that's an acceptable answer.  If on the other hand they mean configuration, then it's not.

With the last - A computer program is not compatible with the system's OS - That is very definitely an issue with installation as far as it being installed on the wrong OS goes.  One could however say that the installation was successful, and that the choice of which package to install was a human error.

6 0
3 years ago
Operating systems that have windows and icons have which type of user interface?
777dan777 [17]
A GUI (Graphical User Interface)
4 0
4 years ago
Other questions:
  • Using a second hash function to compute increments for probe increments is called
    15·1 answer
  • To type the letter address, _________ space from the dateline
    9·2 answers
  • What feature should an administrator use to meet these requirements?
    8·1 answer
  • Which of the following is the definition of Internet Protocol Security ( IPSec)? A remote access client/server protocol. It is a
    13·2 answers
  • What is computer hacking? describe some examples
    6·1 answer
  • You notice that it’s very easy to confuse medications at the community health center where you’re working. They are lined up on
    10·1 answer
  • True or False?Only flying unmanned aircraft over 20lbs requires preparation and safety calculations.
    8·1 answer
  • A hotel salesperson enters sales in a text file. Each line contains the following, separated by semicolons: The name of the clie
    8·1 answer
  • What G-Suite Apps integrate with Forms
    14·2 answers
  • Write getfirstroot and getsecondroot to return the first and second roots. return a domain_error is there is no first or second
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!