So I'm supposed to convert seconds to hours...
I went to class yesterday and the teacher says you should be on each lab for about 30 minutes and you should be done, but it takes me at least 4-5 hours to get everything together... I'm doubting whether this is right for me...I like working on this but man I take too much time?
having said that, I'm having problems dividing seconds into hours to get it in the standard time format and the am/pm time format. It looks easy, since you divide 60 by the seconds entered to get hours, divide by 60 again to get the minute then again to get seconds...but it comes out weird?
Quote:
1. Divide the seconds entered by the user by the number of seconds in an hour
(SECONDS_X_HOUR), the result will be the hours in standard time.
2. Compute the remainder of seconds entered by the user by the number of seconds
in an hour (SECONDS_X_HOUR).
3. Divide the remainder obtained in the previous step by the number of seconds in a
minute (SECONDS_X_MINUTE), the result of this division will be the minutes.
4. The remainder of this last division will be the seconds.
Quote:
int SECONDS_X_HOUR = 3600;
int SECONDS_X_MINUTE = 60;
int AM_PERIOD = 43199;
System.out.print("Please enter the time in seconds: ");
long Answer = keyboard.nextLong();
if (Answer < 0){
System.out.println("You must enter a number bigger than 0!");
}
else {
// Standard Format
double standardHour = (Answer / SECONDS_X_HOUR);
double standardMinute = ((standardHour%) /SECONDS_X_MINUTE);
double standardSecond = ((standardMinute%) / SECONDS_X_MINUTE);
System.out.println("Standard Format: " + standardHour + "h., " + standardMinute + "m., " + standardSecond + "s.");
and here's what I've come with, and there is an error on the standardMinute and standardSecond wit the % (Syntax error). at first I just divided the standardHour by seconds_x_minute and standardminute by seconds_x minute but number for hours, minutes and seconds come out the same (figured I pretty much divided the same number for all 3 cases but i'm not too sure). Also I'm not even sure if I'm using the correct data type?