Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

create a c + + program Create a class Electric _ Car It has an attribute Battery _ Level ( type int ) for a

create a c ++ program Create a class Electric_Car
It has an attribute Battery_Level (type int) for a value from
0 to 100%
Make Recharge() function that adds a number 1 to the
Battery_Level.
Make Show_Bat() function that shows current Battery_Level on
screen.
Q1B. Create a class Petrol_Car
It has an attribute Fuel_Level (type double) for a value from
0 to 50 Liter
Make Fill_Up() function that adds a number 0.5 to the
FuelLevel.
Make Show_Fuel() function that shows current Fuel_Level on
screen.
Petrol_Car
double Fuel_Level
Fill_Up()
Show_Fuel()
Hybrid_Car
char Running_Mode
Switch_Mode(char mode)
Run()
Electric_Car
int Battery_Level
void Recharge()
Show_Bat()
Object Oriented Programming Lab 10
49
Q1C. Create a class Hybrid_Car
It has an attribute Running_Mode (type chr).
o If Running_Mode is b then car is on Battery mode.
o If Running_Mode is f then car is on Fuel mode.
Make Switch_Mode(char mode) function that changes the
RunninMode to b or f based on function arguments.
Make Run() function that
o subtracts 1 from Battery_Level if car is on Battery mode
o subtracts 0.5 from Fuel_Level if car is on Fuel mode.
Q1D. Make an Object of Hybrid_Car in main() function and show the
simulation results on screen.
Generate random numbers from 0 to 5
o If number equals to 0, call Fill_Up()
o If number equals to 1, call Recharge()
o If number equals to 2, call Switch_Mode('b')
o If number equals to 3, call Switch_Mode('f')
o If number equals to 4, call Run()
o If number equals to 5, call Run()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And SQL

Authors: Lucy Scott

3rd Edition

1087899699, 978-1087899695

More Books

Students also viewed these Databases questions