Tony Docherty wrote:
Achyut Sharma wrote:naah..unable to make any logical statement for part 6...moving ON >>
anyways thanks.
Giving up when you get stuck is not the best attitude to have when learning to program because you're going to constantly find situations where you get stuck like this and you need to ask more questions so we can do a better job of explaining how to continue rather than moving on to the next problem.
As it happens it looks like the advice I gave wasn't correct as I had misunderstood the question. Ryan's post made me reread your original post and he's on the right lines. If you want to know more post a reply and I'll explain further.
Just read your message,so i did it.
int hour = 18;
int minute = 15;
int second = 30;
double pastSeconds = (hour * 3600) + (minute * 60) + second;
double totalSeconds = 24 * 3600;
double remainingSeconds = totalSeconds - pastSeconds;
int newHour = 19;
int newMinute = 21;
int newSecond = 40;
System.out.print("Past Seconds since midnight --> ");
System.out.println(pastSeconds);
System.out.print("Remaining seconds for midnight --> ");
System.out.println(remainingSeconds);
System.out.print("Percent of the day passed --> ");
System.out.println(pastSeconds * 100 / totalSeconds);
System.out.print("Percent of the day remaining --> ");
System.out.println(100 - (pastSeconds * 100 / totalSeconds));
System.out.println("Elapsed time will be --> ");
System.out.println((newHour - hour) +":"+ (newMinute - minute) +":"+ (newSecond - second));
}
}
and yes,its kinda hard to stay motivated everyday, maybe because i don't have a proper environment around me or maybe it's just me.
Got my copy of "Head First Java" ,finished first two chapters today and now i'm not reading "Think java" as i've heard about Head first Java positively in these forums,i sincerely hope to finish it.
Anyways many thanks to both of you Ryan and Tony