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]
3 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]3 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
Select the correct answer.
True [87]

Answer:

office access cars

Explanation:

<em><u>HOPE</u></em><em><u> </u></em><em><u>THIS</u></em><em><u> </u></em><em><u>WILL</u></em><em><u> </u></em><em><u>HELP</u></em><em><u> </u></em><em><u>U</u></em><em><u>,</u></em><em><u> </u></em><em><u>MARK</u></em><em><u> </u></em><em><u>ME</u></em><em><u> </u></em><em><u>AS</u></em><em><u> </u></em><em><u>A</u></em><em><u> </u></em><em><u>BRAINLIST</u></em>

3 0
3 years ago
Is C++ a high-level or low-level programming language? What about HTML?
N76 [4]

Answer:

c++ is low level

html high level

Explanation:

6 0
2 years ago
What is software?
bogdanovich [222]

Answer:

B

Explanation:

3 0
3 years ago
Read 2 more answers
Give three reasons why resistors are important in a circuit.​
Zolol [24]
To reduce current flow
To adjust signal levels
To divide voltages
5 0
1 year ago
Which of these substances is a very important natural resource that is useful in the making of computer chips?
Arisa [49]

Silicon is the conductive material used in making Computer Chips. Krypton only exists in the DC Universe, Granite is a rock and Boron is used for rocket thruster ignitors and other pyrotechnic things.

8 0
3 years ago
Read 2 more answers
Other questions:
  • . String literals are surrounded by _____ quotes
    14·1 answer
  • William found out that someone used his report on American culture without his permission. What is William a victim of?
    13·2 answers
  • How many 16ths are in 3/8 of an inch
    12·1 answer
  • The _____ is a blinking vertical line that indicates where the next typed character will appear. scroll box sheet tab insertion
    7·1 answer
  • Which of the following terms best describes the security domain that relates to how data is classified and valued?
    14·1 answer
  • Importance of type casting in programming ​
    5·1 answer
  • Which of these skills are used in game design?
    8·1 answer
  • What is the fullform of BIT​
    11·1 answer
  • Which control segment communicates with the satellites? OA master stations O B. monitoring stations O C. ground antennas D. cont
    7·1 answer
  • A network of computers that provides access to information on the web.
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!