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
Access your Practice Lab titles Access your exercise content Reports and files Access your settings Access help and support Comp
Degger [83]

Answer:

The extension for a shell script in windows ends with a .ps1 and for the extension for linux it is .sh, not quite sure for OSX.

4 0
3 years ago
How does having a flexible mind help you become a better employee?
Effectus [21]
You don't get stumped on a issue or provlem. you a creative to find a solution and a way around it.
8 0
3 years ago
For this lab, you will work on a simple GUI application. The starting point for your work consists of four files (TextCollage, D
Bad White [126]

The answer & explanation for this question is given in the attachment below.

Download docx
4 0
3 years ago
Write a program that asks the user for three strings. Then, print out whether the first string concatenated to the second string
ipn [44]

Answer:

import java.util.Scanner;

public class num5 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter The First String");

       String str1 = in.next();

       System.out.println("Enter The Second String");

       String str2 = in.next();

       System.out.println("Enter The Third String");

       String str3 = in.next();

       String oneAndTwo = str1+str2;

       if(str3.equals(oneAndTwo)){

           System.out.println(str1+" + "+str2+" is equal to "+str3+"!");

       }

       else

           System.out.println(str1+" + "+str2+" is not equal to "+str3+"!");

   }

}

Explanation:

  • Implemented in Using Java Programming Language
  • Import Scanner Class to prompt and receive users' input
  • Create three string variables and store the three values entered by the user (str1, str2 and str3)
  • Concatenate str1 and str2 using the + operator and assign to a new variable
  • Use the if statement with Java's .equals() method to check for equality of the new string with the third string
  • Print the appropriate message if the equal or not
8 0
3 years ago
Explain each kind of pointer and for what it is appropriate.
Mademuasel [1]

Pointer: A pointer is a variable which holds the address of other variable of the specified data type(like int,float,char). In programming we basically use pointers to store the other variable's address.

3 0
3 years ago
Read 2 more answers
Other questions:
  • Memories Record Players Company has seen most of its competition slip away, and it now holds 95 percent of the market share for
    5·1 answer
  • A​ client-server application that requires nothing more than a browser is called​ ________.
    8·2 answers
  • Show the output waveform of an AND gate with the inputs A, B,
    5·1 answer
  • The area surrounding your car that can't be seen from the driver's seat is called
    14·2 answers
  • What type of photography is represented by a photograph of a dog on a beach ?
    11·1 answer
  • The primary purpose of an operating system is: To provide a software interface between the hardware and the application programs
    11·1 answer
  • Just took a test and I got 5 wrong and I wanted to know the correct answers
    10·1 answer
  • 1110011*110011 binary multiplication
    9·2 answers
  • Moving images of real event​
    12·2 answers
  • From the introductory conversation chip and anna shared, which elements mentioned might suggest the use of case tools?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!