Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,263 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,501 people online right now. Registration is fast and FREE... Join Now!




Pleas need help with an C++ exercise

 
Reply to this topicStart new topic

Pleas need help with an C++ exercise, an exercise from a book of C++

charliedrums
6 Nov, 2006 - 10:55 AM
Post #1

New D.I.C Head
*

Joined: 6 Nov, 2006
Posts: 1


My Contributions
Ok here’s the thing. I’m taking an MS visual C++ class in the Interamerican University in Bayamón Puerto Rico. The thing is that my professor is the worst professor in the history of any class ever taken any ware in the world. I have a C++ project due to the 27 of this month and to tell everyone the truth I don’t have a clue about what I have to do in this project. If anyone can help me with the code for this problem it will be greatly appreciated. The problem is from the book essential C++ for engineers and scientists second edition (Jeri R. Hanly). It’s the problem #5 of page 271. Here’s how it goes:

“Design and implement a class to model a battery. A battery abject 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 devise, 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 amps (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 5*10^6j. 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.”

And that’s the whole problem. Any help whatsoever will be greatly appreciated. Thanks in advance.

User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Pleas Need Help With An C++ Exercise
6 Nov, 2006 - 11:26 AM
Post #2

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,230



Thanked: 40 times
Dream Kudos: 25
My Contributions
Hi,

The site has a policy by which we prefer to see a good faith effort on the part of the user before providing source code in the matter of academic assignments. Please post the code you've written and our members would be pleased to guide you.

Welcome to dream in code!
User is offlineProfile CardPM
+Quote Post

NyeNye
RE: Pleas Need Help With An C++ Exercise
6 Nov, 2006 - 05:36 PM
Post #3

D.I.C Head
**

Joined: 24 Sep, 2006
Posts: 248


My Contributions
Show some effort...

Policy rules..

LoL
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 07:17PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month