-
October 6th, 2009, 12:28 AM
#1
Another C++ problem
Sorry to keep posting my C++ programing problems but I'm still learning and have questions.
so here is my question I'm trying to take a float variable that is holding the amount of seconds it take for something to happen such as 1928.61582 seconds and break that down into minutes and seconds.
now transTime needs to be a float or i loose the decimal places rite from the beginning which is not good because my time will be off but my code will not work unless every thing is an int which doesn't work either because i need the time for seconds out to the 5th decimal place and if its an int and i force the decimal place i just get all zeros which isnt any good any way. hope you guys understand if not just ask more questions.
float transTime = 1928.61582 // total seconds that something takes to happen
int minSec = 60 // number of seconds in a minute
int minutes = 0
float seconds = 0
minutes = transTime / minSec; // gives me the minutes
seconds = transTime % minSec; // gives me the seconds
cout << "The ammount of time is: " << '\n' // print out time
<< fixed << showpoint << minutes << " minutes " << setprecision(5) << seconds << " seconds" << '\n';
Similar Threads
-
By The Texan in forum Operating Systems
Replies: 16
Last Post: June 22nd, 2006, 08:04 PM
-
By AngelicKnight in forum General Computer Discussions
Replies: 14
Last Post: June 15th, 2006, 04:04 AM
-
By Tedob1 in forum Tech Humor
Replies: 0
Last Post: December 23rd, 2002, 04:58 PM
-
By Rna in forum General Programming Questions
Replies: 4
Last Post: May 22nd, 2002, 07:03 AM
-
By thesecretfire in forum Hardware
Replies: 16
Last Post: May 17th, 2002, 12:31 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|