Write a C++ program to calculate the gravity of the petrol using multiple inheritance Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement. Consider a class Liquid with the following protected member variable. Datatype float Variables density Include appropriate getter and setters. Consider a class Fuel with the following protected member variable. Variables Datatype float rate Include appropriate getters and setters Consider a derived class Petrol derived from Liquid and Fuel and it contains the following member variables. Data Type float int Variable gravity thermalConductivity Include appropriate getters and setters Consider a class PetrolBO with the following method Method void display(Petrol p) This method is used to display the petrol details. Method description In the main method, inputs are obtained from the user and access the display method of PetrolBO by creating instances. Note:To calculate gravity use gravity = (density/997.0). Input and Output format: Refer to sample input and output for other further details and format of the output. [All texts in bold corresponds to the input and rest are output] Sample Input and Output: Enter the details Enter the density of the petrol 560 Enter the rate of the petrol 89 Enter the thermal conductivity of the petrol 465 Density: 560 Rate:89 Thermal Conductivity: 465 Gravity:0.561685
Write a C++ program to calculate the gravity of the petrol using multiple inheritance Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement. Consider a class Liquid with the following protected member variable. Datatype float Variables density Include appropriate getter and setters. Consider a class Fuel with the following protected member variable. Variables Datatype float rate Include appropriate getters and setters Consider a derived class Petrol derived from Liquid and Fuel and it contains the following member variables. Data Type float int Variable gravity thermalConductivity Include appropriate getters and setters Consider a class PetrolBO with the following method Method void display(Petrol p) This method is used to display the petrol details. Method description In the main method, inputs are obtained from the user and access the display method of PetrolBO by creating instances. Note:To calculate gravity use gravity = (density/997.0). Input and Output format: Refer to sample input and output for other further details and format of the output. [All texts in bold corresponds to the input and rest are output] Sample Input and Output: Enter the details Enter the density of the petrol 560 Enter the rate of the petrol 89 Enter the thermal conductivity of the petrol 465 Density: 560 Rate:89 Thermal Conductivity: 465 Gravity:0.561685
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter11: Inheritance And Composition
Section: Chapter Questions
Problem 1PE: In Chapter 10, the class clockType was designed to implement the time of day in a program. Certain...
Related questions
Question
1) QUESTION PROVIDED IN ATTACH IMAGE KINDLY SEE.
2) IF THERE IS A DECIMAL IN OUTPUT WHETHER IT'S ZERO OR TWO PLACE DECIMAL YOU MUST MATCH AS IT IS WITH QUESTION OUTPUT NO MISMATCH IN OUTPUT ACCEPTED
AND BELOW TEMPLATES PROVIDED CHECK THIS BEFORE MAKING SOLUTION ( main.cpp , petrol.cpp , PetrolBo..cpp , liquid.cpp , fuel.cpp )
----------------- TEMPLATES BELOW FOR SOLUTION -----------------------
Petrol.cpp
#include<iostream> #include "Liquid.cpp" #include "Fuel.cpp" using namespace std; class Petrol //Fill the code { public: float gravity; int thermalConductivity; //Fill your code here }; |
petrolBo.cpp
#include<iostream> using namespace std; #include"Petrol.cpp" class PetrolBO { public: void display(Petrol p) { //Fill your code here } }; |
Fuel.cpp
#include<iostream> using namespace std; class Fuel { protected: float rate; public: //Fill your code here }; |
Liquid.cpp
#include<iostream> using namespace std; class Liquid { protected: float density; public: // Fill your code here }; |
Main.cpp
#include<iostream> using namespace std; #include "PetrolBO.cpp" int main() { cout<<"Enter the details\n"; cout<<"Enter the density of the petrol"; cin>>density; cout<<"Enter the rate of the petrol"; cin>>rate; cout<<"Enter the thermal conductivity of the petrol"<<endl; cin>>thermalConductivity; //Fill your code here return 0; } |
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning