We want to design a program to manage battery models.
(a) Define a function Recharge that sets a battery of type BatteryModel representing the present energy reserve to its maximum capacity.
The following formula are to be used in your design:
p = vi p is the power in watts (W)
v is the voltage in volts (V)
w = pt i is the current in amps (A)
w is the energy in joules (J)
t is the time in seconds (s)
(b) Create a main function that tests your functions by creating a 12-V automobile battery object of type BatteryModel, that has a maximum energy storage of 5×106
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. 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.
Comments
Leave a comment