October 6th, 2009, 12:28 AM
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';
By The Texan in forum Operating Systems
Last Post: June 22nd, 2006, 08:04 PM
By AngelicKnight in forum General Computer Discussions
Last Post: June 15th, 2006, 04:04 AM
By Tedob1 in forum Tech Humor
Last Post: December 23rd, 2002, 03:58 PM
By Rna in forum General Programming Questions
Last Post: May 22nd, 2002, 07:03 AM
By thesecretfire in forum Hardware
Last Post: May 17th, 2002, 12:31 AM