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.

Answers

Answer 1

Answer:

Explanation:

The following code is written in Java and contains each of the methods requested working and performing the requested functions.

class GasTank {

   double amount = 0;

   double capacity;

   public void GasTank(double capacity) {

       this.capacity = capacity;

   }

   public void addGas(double gasAmount) {

       this.amount += gasAmount;

       if (this.amount > this.capacity) {

           this.amount = this.capacity;

       }

   }

   public void useGas(double useGas) {

       this.amount -= useGas;

       if (this.amount < 0) {

           this.amount = 0;

       }

   }

   public boolean isEmpty() {

       if (this.amount < 0.1) {

           return true;

       } else {

           return false;

       }

   }

   public boolean isFull() {

       if (this.amount > (this.capacity - 0.1)) {

           return true;

       } else {

           return false;

       }

   }

   public double getGasLevel() {

       return this.amount;

   }

}


Related Questions

Describe white blood cells you see at 10X?

Answers

Answer:

White blood cells are part of the body's immune system. They help the body fight infection and other diseases. Types of white blood cells are granulocytes (neutrophils, eosinophils, and basophils), monocytes, and lymphocytes (T cells and B cells). ... Also called leukocyte and WBC.

Explanation:

Predict the future that social media will have on society or the environment.

Answers

Answer:

Social networks are becoming more and more popular. More than 80% of the 4.66 billion people on the planet with access to the internet are social network users… and this share is expected to grow!

Society will drift to technology and rely on it more.

Environment wouldn't be taken cared of, and may be damaged.

Explanation:

Answer:

The Influence of Social media is being used in ways that shape politics, business, world culture, education, careers, innovation, and more.

Explanation:

The Influence of Social media is being used in ways that shape politics, business, world culture, education, careers, innovation, and more.

What function affects the cookies downloaded into the host when playing a video clip?


security

privacy

APIs

embedded code

Answers

Answer:

Privacy

Explanation:

Citations that are ______________________________ can be used to build a bibliography when needed. [Create and Modify Citation Sources]
Question 1 options:

underlined

bolded

marked

italics

Answers

Answer:

I think the best option would be C. Marked

Explanation:

hope this helps and sorry if it is incorrect.

Jennifer has written a short story for children. What should be her last step before she submits the story for publication?

Answers

Answer: proofreading

Explanation:

The options include:

A. proofreading

B) editing

C) accepting track changes

D) rejecting track changes

Jennifer's last step before she submits the story for publication should be proofreading. Proofreading simply refers to the checking of errors in an article, story or text before such article or text is published.

Proofreading is the final stage when one is writing before it's published. When a story is proofread, spelling, formatting issues, punctuation marks and every other mistakes are checked and removed.

Which one of these is a common result of good peer communication in the workplace?



an increased number of coworkers


a decreased number of coworkers


decreased product


increased product​

Answers

Answer:

increased product.

Hope you have a nice day.

In the current situation, how do you access information as a student? How will you integrate the use of ICT in your daily life and your chosen track?

Answers

Answer:

Explanation:

As a computer science student information is accessed in every possible way. This can be through a local school lan network, mobile devices, e-mail, etc. All of these help information flow to and from various people and makes obtaining this information incredibly simple as a student. Especially in the field of computer science, I need to integrate as many ICT devices with me in my everyday life, to send emails, check calendar updates, research information on the web, check school reports, and even speak with clients.

who plays oblox .............................

Answers

Answer:

Me

Explanation:

MEEEE!!! i love scary games

Display the IP address of the default gateway of this device.

Answers

Answer:

ipconfig

Explanation:

Type ipconfig and look for a Default Gateway entry that is not blank.

it is a JavaScript property used to call a function after a specified time, in milliseconds​

Answers

Answer:

setTimeout is a native JavaScript function (although it can be used with a library such as jQuery, as we'll see later on), which calls a function or executes a code snippet after a specified delay (in milliseconds).

Answer:

setTimeout is a native JavaScript function (although it can be used with a library such as jQuery, as we'll see later on), which calls a function or executes a code snippet after a specified delay (in milliseconds).



WAP to read number(s) from keyboard until a zero number is keyed in. And print the sum of entered numbers.​

Answers

Answer:

Worship And Pray -LIVE LAUGH WAP

Answer and Explanation:

in Java:

import java.util.Scanner;

public class NumberReader

{

 public static void main(String[]args)

 {

     Scanner in = new Scanner(System.in);

     

     int keyNum = 10;

      while (keyNum != 0)

      {      

          keyNum = in.nextInt();

          sum += keyNum

      }

      System.out.println(sum);

 }

}

two ways in which some culter views that exist may affect a relationship negatively​

Answers

Answer:

some people say different culture less they get along

Explanation: or more

Briana designs a science fair experiment where she drops a basketball, tennis ball and golf ball from three different heights. She conducts ten trials where she drops each type of ball from a height of 100 cm, 80 cm, and 50 cm. She records the height of each ball after it bounces off the ground. Briana's teacher hands her science fair proposal back to her and asks her to fix her mistake. How should she fix her experiment?

Answers

A semi-circle is a half circle. Find the area of a semi-circle with a radius of 8.6 meters.

The area of the semi-circle is

QUESTION 4 of 10: What term refers to the basic characteristics of a population segment, such as gender, age, and income?

Answers

272727727272727226282829292
Does it offer multiple choices?

A citation and its ____________________ can be entered at the same time. [Insert Citations]
Question 4 options:

name

date

source

table of contents

Answers

Answer: source

Explanation:

A citation and its source can be entered at the same time. Hence option c is correct.

What is citation?

Citation is defined as how you disclose to your readers that a particular passage in your work was taken from another source. Identifying the sources you used to obtain your knowledge can demonstrate to the reader that you did thorough investigation. to recognize and respect other scholars' work by giving them due credit.

Select the phrase or sentence you wish to cite by clicking at the end of it, and then select Insert Citations from the Citations & Bibliography group on the References tab. Choose the citation you want to use from the list provided under "Insert Citation."

Thus, a citation and its source can be entered at the same time. Hence option c is correct.

To learn more about citation, refer to the link below:

https://brainly.com/question/1272936

#SPJ2

Which of the following algorithmic efficiencies would be considered LEAST efficient?

A. Linear
B. Constant
C. Polynomial
D. Exponential

Answers

Answer:exponential

Explanation: I believe

Your program has a two-dimensional array, scores. You are implementing your array with lists. Each member in the array is a pair of
scores, composed of [your team score, the opponent's score).
Which line of code will add a new pair of scores to the array?
scores.insert(6,2)
O scores.append([6.2])
O scores.insert[62]
O scores.append(6,2)

Answers

Answer:

scores.append([6, 2])

Or simply D

Explanation:

Note: Be sure to look carefully or you'll get tripped up. Trust me, I know!

How are online sources used? Check all that apply.
as a way to learn from others
as a way to play games
as a way to find information
as a way to socialize with others
as a way to copy the work of others

Answers

Answer:

As a way to learn from others, as a way to find information

Explanation:

When you read about lets say how to make a certain cookie mix you like your learning from someone else. The source is also helping you find information about that topic you want. Its not supposed to be a way for entertainment or games, its not a platform for you to talk to  others, and not made for you to just copy and take credit.

Answer: a, c, d

Explanation: edge 2021

By default, tables are sorted in ascending order by this.


What’s the answer?

Answers

Answer:

Record number

Explanation:

It simply can't be "data type" as there cant be more than one data type in a field. It won't be "primary key field" either as primary keys only set the field as unique. You can test this by changing the primary key to a different field. But for simplicity's sake, I did this experiment for you.

As you can see in the first and second attachments, ID is the primary key, set default by the program.

But when I set Field 8 as the primary key, shown in the third attachment, field 8 doesn't sort, shown in the fourth attachment.

Answer:

By default, tables are sorted in ascending order by record number.

The ________________________ option allows one to start a numbered list on any number desired. [Set Starting Number Values]
Question 7 options:

Number Formats

Change List Level

Define New Number Format

Set Numbering Value

Answers

Answer:

Set Numbering Value.

Explanation:

Microsoft Word refers to a word processing software application or program developed by Microsoft Inc. to enable its users to type, format and save text-based documents.

In Microsoft Word 2019, the users are availed with the ability to edit the word document in the following view type;

I. View Mode.

II. Print Mode.

III. Drift Layout.

A numbered list can be defined as a list of items that are ordered numerically or sorted sequentially.

Basically, it is best suited for steps or procedures that are to be done sequentially or in order i.e in an ascending order. Thus, a numbered list is an ordered list that starts from 1.

The Set Numbering Value option allows one to start a numbered list on any number desired. To automatically create a numbered list in Microsoft Word, you should press 1 followed by a period, leave a space, type a text and then press the enter button.

Plz help
Match each engineering job role to its description

Answers

Answer:

Check image, correct on PLATO

Explanation:

The correct matches of each engineering job role to its description are mentioned below.

What is engineering?

Engineering is the application of science and mathematics to problem-solving. While scientists and innovators create new ideas, it is engineers that put these ideas into practice.

It is the integration of scientific concepts to the design and construction of machinery, structures, and other objects such as bridges, tunnels, roads, automobiles, and buildings.

Each engineering job role's correct match to its description is shown here.

Heads the engineering department and ensures that it operates smoothly  - chief engineerperforms administrative work to ensure projects comply with engineering codes and standards  - office engineerperforms a variety of onsite tasks, such as supervision and equipment installation -  field engineerensures projects end on time through careful planning and organization - project engineerensures proper sequencing of events to minimize project duration - planning engineer.

Learn more about engineering here:

https://brainly.com/question/19117846

#SPJ2

all of the following are computer hardware servicing tools EXCEPT​

Answers

Answer:

Shovel

Explanation:

It is best to use ____________________ styles to get a table of contents to build easily. [Insert a Table of Contents]
Question 5 options:

font

pretty

heading

black

Answers

Answer: heading

Explanation:

It is best to use the heading styles to get a table of contents to build easily. In this case, when the table of contents us inserted, a section will be created for each heading.

When one applies the heading style, one is simply telling Ms Word that a new section in the document is about to begin. The heading style when used for the chapters can be used to know the number of sections that are contained in a document.

Need answer quick plz.

Fill in the blank with the correct response.

A colleague excitedly tells you she has created a interface component for SPSS, a statistics software program. She

has created a

Answers

Answer:

SPSS

IS THE ANSWER

IHOPEIT WILL HELP YOU

Answer:

wassup with it bro i don't even know the answer and i just want the points

Explanation:

What is the relation, if any, between a web master and a web developer?

A) They are simply different titles that different companies may use for the exact same job.

B) While a web developer maintains a company's websites, the web master creates them in the first place.

C) There is no relation between them as they handle entirely different aspects of a company's web presence

D) While a web master maintains a company's websites, the web developer creates them in the first place.

Answers

I would say D, it makes sense to me.

Answer:

a)

Explanation:

they are the same

How does setting user permissions increase the security of a system?

Answers

Answer: This can allow for less hackers to acquire your most essential and private information. It will be kept private to you and only others you share with.

Explanation: For example, if I wanted to edit a document without being given the consent to do so this will breach the security of user permissions, but if the individual was to set the document to view only, I would not have access to edit or even change little aspects of it.

Does anyone have 2.19.4 Guess a number 2.0 code for codehs?

Answers

Python is a high-level, universally interpreted programming language. It seeks to encourage a clear, succinct programming approach.

What is a programming language?

A method of notation for creating computer programs is known as a programming language. The majority of formal programming languages are text-based, though they can also be graphical. They are a sort of programming language.

Syntax and semantics, which are often specified by a formal language, make up the two parts of the definition of a programming language. Some languages have a specification paper that serves as their definition, while others have a dominant implementation that serves as their reference.

Both exist in certain languages, with the base language being defined by a standard and extensions frequently drawn from the most popular implementation.

The branch of computer science that investigates the creation, use, analysis, characterization, and classification of programming languages is known as programming language theory.

Learn more about programming language, here

https://brainly.com/question/23959041

#SPJ5

A basic implementation of the "Guess a Number 2.0" game in Python. You can adapt this code to your specific needs on CodeHS or any other platform.

import random

def play_game():

   secret_number = random.randint(1, 100)

   num_guesses = 0

   print("Welcome to Guess a Number 2.0!")

   print("I'm thinking of a number between 1 and 100.")

   while True:

       guess = int(input("Take a guess: "))

       num_guesses += 1

       if guess < secret_number:

           print("Too low!")

       elif guess > secret_number:

           print("Too high!")

       else:

           print(f"Congratulations! You found the number in {num_guesses} guesses.")

           break

   play_again = input("Do you want to play again? (yes/no): ")

   if play_again.lower() == "yes":

       play_game()

   else:

       print("Thank you for playing!")

play_game()

This is a basic implementation of the "Guess a Number 2.0" game in Python. The code generates a random secret number between 1 and 100 and prompts the user to guess the number. It provides feedback ("Too low!" or "Too high!") based on the user's guess and continues until the correct number is guessed. Afterward, it gives the option to play again or exit the game.

Learn more about python on:

https://brainly.com/question/30391554

#SPJ6

In what situations might you need to use a function that calls another function?

Answers

Answer:

Explanation:

It is important to understand that each of the functions we write can be used and called from other functions we write. This is one of the most important ways that computer programmers take a large problem and break it down into a group of smaller problems.

Brandon realized that his program wasn’t running properly because he used a colon instead of a semi-colon. What kind of error did Brandon make?
syntax error

Boolean error?

logic error?

iteration error?

Answers

Answer:

Syntax Error

Explanation:

Syntax Errors a simple errors where you could forget something simple like a comma or maybe misspell a word.

Answer:

The error Brandon made by using a colon instead of a semi-colon is Syntax error

Identify what a computer needs to
communicate sound:
Driver
Digital sound
Mouse
Keyboard
DONE

Answers

Digital sound because you want be able to hear

Answer:

A B

Explanation:

I got it right

Other Questions
how to say inspire in Afrikaans Who were the abolitionists?PLS I WILL GIVE BRAINLY POINTS!!! Cheyenne works 15 hours a week at the movie theater. She earns $8 an hour. Which statement about her weekly income is true? F. Her net income is more than $120. G. Her gross income is less than $120. H. Her net income is less than $120. J. Her gross income is more than $120. PLEASE HELP!! WILL MARK BRAINLIEST IF RIGHT!!!!!!! ^0^Lines k and l are parallel. Lines m and n intersect lines k and l to form 2 triangles. Given k Is parallel to l, what can you conclude about these triangles? Check all that apply.1. Vertical angles prove Angle1 Is congruent to Angle4.2. Alternate exterior angles prove Angle5 Is congruent to Angle3.3. Angle5 and Angle3 are alternate interior angles.4. The ratios of the corresponding angles are equivalent.5. The triangles are similar because all corresponding angles are congruent. Can someone please give me the answer? Which expression is equivalent to (3 + 4x)?A. 3 4x B. 3 + 4x C. 3 +4x D. 3 - 4x Is this right or what one is it? Can someone plz help me with this one problem plz plz The total number of cells in an organism increases as a result of which process?A.respirationB.photosynthesisC.cell division i need help nowwwww hurrrryyyD.fermentation and its not B Solve for x: cos (x - 5) = sin (4x + + 10) What impact did the Donner Party have on the United States? WILL GIVE BRAINLIEST!!!! what is the inverse of the equation y=x^2 what are the causes of Drought 4. How many bricks will be required to build a wall 30 m long, 50 cm thick and2.5 m high with each brick being 20 cm long, 10 cm wide, and 7.5 cm thick? Explain how regeneration can help to solve urban problems Gap, Inc. owns Banana Republic, Old Navy, and Gap brands, all of which are brands of clothing targeting different segments of the clothing and accessories markets. Banana Republic is positioned as upscale, Old Navy is positioned as value, and Gap is positioned as targeting younger consumers. Gap, Inc.'s brands are intended to help the company pursue a(n) ______ strategy. why do cars have a push start button??? What's the value of (3x+12) why must we be Catholic help pls this is due today