Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help Design and implement a class to model a battery. A battery object should know its voltage, how much energy it is capable of

Please help Design and implement a class to model a battery. A battery object should know its voltage, how much energy it is capable of storing, and how much energy it is currently storing (in joules). Include the following member functions. powerDevice: Given the current of an electrical device (amps) and the time the device is to be powered by the battery (seconds), this function determines whether the battery's energy reserve is adequate to power the device. If so, the function updates its energy reserve by subtracting the energy consumed and returns the value true. Otherwise it returns the value false and leaves the energy reserve unchanged. maxTime: Given the current of an electrical device, the function returns the number of seconds the battery can operate the device before it is fully discharged. This function does not modify the energy reserve. reCharge: This function sets the battery's component representing the present energy reserve to its maximum capacity. Use the following equations in your design. p=vi p= power in watts (W) v= voltage in volts (V) w=pt i= current in amos (A) w= energy in joules (J) t= time in seconds (s) For this simulation, neglect any loss of energy in the transfer from battery to device. Create a main function that tests your class by creating an object to model a 12-V automobile battery with a maximum energy storage of 5x10^6 J. Use the battery to power a 4-A light for 15 minutes. Then find out how long the battery's remaining energy could power an 8-A device. After recharging the battery, ask again how long it could operate an 8-A device. program is in C++

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

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago