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
Nataly [62]
4 years ago
13

Write the interface (.h file) of a class GasTank containing: A data member named amount of type double. A data member named capa

city of type double. A constructor that accepts a parameter of type double. A function named addGas that accepts a parameter of type double and returns no value. A function named useGas that accepts a parameter of type double and returns no value. A function named isEmpty that accepts no parameters and returns a boolean value. A function named isFull that accepts no parameters and returns a boolean value. A function named getGasLevel that accepts no parameters and returns a double. A function named fillUp that accepts no parameters and returns a double.
Computers and Technology
1 answer:
REY [17]4 years ago
7 0

Answer:

The interface(.h file) in cpp language is shown below.

#ifndef GASTANK_H

#define GASTANK_H

class GasTank

{

   //variables as mentioned

   double amount, capacity;

   //constructor

   GasTank(double p);

   //method to add gas amount

   void addGas( double g);

   //method to subtract used gas amount

   void useGas(double u);

   //method to verify if the tank is empty

   bool isEmpty();

   //method to verify if the tank is full

   bool isFull();

   //method to return current gas amount in the tank

   double getGasLevel();

   //method to return amount of gas to be filled in the tank

   double fillUp();    

};

#endif

Explanation:

1. The class GasTank ends with a semicolon.

2. The variables are declared with double datatype as mentioned.

3. The constructor is declared accepting double parameter.

4. The methods, addGas() and useGas(), accept double parameter and return no value.

5. The methods, isEmpty() and isFull() and getGasLevel() return boolean, boolean and double values, respectively.

6. The header file begins with the following keywords.

#ifndef GASTANK_H

#define GASTANK_H

7. The header file ends with the following keyword.

#endif

8. This header file is saved as GasTank.h, the name of the class with .h extension.

9. This header file is imported in the program using the following code. The header file is enclosed within quotes and not brackets like the iostream header file.

#include "GasTank.h"

10. All the code beginning with # do not end with any punctuation mark.

11. All the methods in the header file are only declared and none of the methods have any definition.

12. The program which uses this header file is responsible to define all the methods in the header file and use all the variables in the header file.

13. The cpp language does not supports interface directly. Hence, the header file is a way to implement an interface which is a feature of completely object-oriented programming languages.

14. All the requirements mentioned are implemented in the above header file.

You might be interested in
Suppose you are purchasing something online on the Internet. At the website, you get a 10% discount if you are a member. Additio
patriot [66]

Answer:

<em>The function is written in C++</em>

void calc_discount(double amount,bool member)

{

 double discount;

 if(member)

 {

  discount = amount - 0.10 * amount - 0.05 * amount;

 }

 else

 {

  discount = amount - 0.05 * amount;

 }

 cout<<"Discount = "<<discount;

}

Explanation:

<em>I've included the full source code (including the main method) as an attachment where I use comments as explanations</em>

Download cpp
6 0
3 years ago
A(n) ________ CPU has two processing paths, allowing it to process more than one instruction at a time.
lions [1.4K]
C. Dual-core is the answer
3 0
4 years ago
Read 2 more answers
Assume that name is a variable of type String that has been assigned a value. Write an expression whose value is the first chara
andrezito [222]

Answer:

name.charAt(0);

Explanation:

Given: 'name' is a variable of type String that has been assigned a value.

To determine: an expression whose value is the first character of the value of name.

Let us assume nae is assigned the value "test". So our expression should return the first character , that is 't'.

In order to do this, we can use the charAt method of String object.

String name="test";

char c = name.charAt(0);

Here 0 corresponds to the index of the character we are interested in.

3 0
3 years ago
Haya noticed that college students needed to dress up for presentations but never seemed to have any ties, or at least not very
VashaNatasha [74]

Answer:

I believe it's B

Explanation:

...but is it?

3 0
4 years ago
Four kinds of information a writer must document are: _____. A) common knowledge information B) direct quotation summary of a di
Dmitry_Shevchenko [17]
<span>The four kinds of information a writer must document are: summary of a discussion, original ideas, common knowledge information, and direct quotation. These are the fundamental information one must seek in order to fully understand the document.</span>
6 0
4 years ago
Other questions:
  • What type of wireless connection requires an unobstructed "line of sight" between transmitter and receiver?
    8·1 answer
  • What should you consider when thinking about your target audience?
    12·1 answer
  • Find the area of the regular hexagon below by using the area formula for triangles.
    7·1 answer
  • A research team is studying parallel computing. They want to run parallel process without having to use multiple processors. How
    7·1 answer
  • PowerPoint:
    7·2 answers
  • )In a graph represented by adjacency matrix u can find all the neighbours of a given vertices in ____Operations
    6·1 answer
  • which statement describe “Hackers”? | A. all have the same motive | B. break into other people’s computers | C. may legally brea
    14·1 answer
  • If a base class pointer, p, points to a derived class instance, and both base and derived classes have a method void doIt() whic
    14·1 answer
  • The ability to understand a person's needs or intentions in the workplace is demonstrating
    5·1 answer
  • When did Microsoft released MS-Word 2016? S When did Microsoft released MS - Word 2016​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!