answer.
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]
2 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]2 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
Directions
DanielleElmas [232]

Answer:

is he project for me

Explanation:

3 0
1 year ago
Make a class Employee with a name and salary. Make a class Manager inherit from Employee. Add an instance variable, named depart
sweet [91]

Answer:

see explaination

Explanation:

class Employee

{

String name;

double salary;

void tostring()

{

System.out.println("Employee:\nName: "+name+"\nSalary: "+salary+"\n");

}

Employee(String n,double s)

{

name=n;

salary=s;

}

}

class Manager extends Employee

{

String department;

void tostring()

{

System.out.println("Manager:\nName: "+name+"\nDepartment: "+department+"\nSalary: "+salary+"\n");

}

Manager(String n,double s,String d)

{

super(n,s);

department=d;

}

}

class Executive extends Manager

{

void tostring()

{

System.out.println("Executive:\nName: "+name+"\nDepartment: "+department+"\nSalary: "+salary+"\n");

}

Executive(String n,double s,String d)

{

super(n,s,d);

}

}

public class test

{

public static void main(String args[])

{

Employee e =new Employee("Neo",12000);

e.tostring();

Manager m =new Manager("Cramster",100000,"Homework");

m.tostring();

Executive ex =new Executive("Chuks",1000000,"Homework");

ex.tostring();

}

}

8 0
2 years ago
An Open Authorization (OAuth) access token would have a _____ that tells what the third party app has access to
qaws [65]

Answer:

scope

Explanation:

An Open Authorization refers to a method  that helps to share data using third party services without giving your credentials and there is a mechanism in an Open Authorization that allows to limit the access that the third party app has to an account that is called scope. Because of that, the answer is that an Open Authorization (OAuth) access token would have a scope that tells what the third party app has access to because it is what limits the access the app has to an account and it shows the access given in a consent screen.

3 0
2 years ago
5. You just bought a new hard drive for youYou plan to use this as a secondary hard drive to store allcomputeryour UMA files. On
wel
Format and mount the drive. 
Formatting erases the drive and sets it up so the system can read and write to it.
Mounting the drive allows the system to have access to the drive and read and write to it. 

If you want to get more specific in Windows you can open registry editor and change the paths of the drive to save in the new location.
4 0
2 years ago
Zander is beginning to take college courses to prepare for a career in computer science, which is the study of using logic to cr
scoundrel [369]

The answer is (A. career definition and career requirements  )


7 0
2 years ago
Other questions:
  • The elements in a string type array will be initialized to ____.?
    10·1 answer
  • Which behavior could be acceptable at a classical concert as well as at a ball game? standing for an exceptional performance che
    9·2 answers
  • Ismael would like to insert a question mark symbol in his document. What steps will he need to follow to do that?
    5·2 answers
  • Which of the following is not one of the four methods for classifying the various instances of malware by using the primary trai
    9·1 answer
  • You complete your database, and the company begins using it. Shortly afterwards, two GearUp buyers, Cora and Owen, work together
    9·1 answer
  • Static packet filtering firewalls are limited to ________. inspecting packets for which there are good application proxy filteri
    8·1 answer
  • To reduce costs and the environmental impact of commuting, your company decides to close a number of offices and to provide supp
    11·1 answer
  • Assume you have a variable, budget, that is associated with a positive integer. Assume you have another variable, shopping_list,
    11·1 answer
  • 1. (1 point) Which flag is set when the result of an unsigned arithmetic operation is too large to fit into the destination? 2.
    13·1 answer
  • 1. Used ____________ must be hot drained for 12 hours or crushed before disposal.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!