Achyut Sharma

Greenhorn
+ Follow
since Jan 12, 2017
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Achyut Sharma

Surely, i will ask more questions in near future.
And, wow my first cow!..that's kinda special and,
many thanks for telling me to be mentally strong,i will keep that in my mind.
8 years ago

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
8 years ago
naah..unable to make any logical statement for part 6...moving ON >>
anyways thanks.
8 years ago
This is a problem from "Think Java" book.I'm kinda stuck at the last point(i.e. #6)

Exercise 2.3 The point of this exercise is to (1) use some of the arithmetic
operators, and (2) start thinking about compound entities (like time of day)
that are represented with multiple values.
1. Create a new program called Time.java. From now on, we won’t remind
you to start with a small, working program, but you should.
2. Following the example program in Section 2.4, create variables named
hour, minute, and second. Assign values that are roughly the current
time. Use a 24-hour clock so that at 2pm the value of hour is 14.
3. Make the program calculate and display the number of seconds since
midnight.
4. Calculate and display the number of seconds remaining in the day.
5. Calculate and display the percentage of the day that has passed. You
might run into problems when computing percentages with integers, so
consider using floating-point.
6. Change the values of hour, minute, and second to reflect the current
time. Then write code to compute the elapsed time since you started
working on this exercise.


Need some hint, i have solved other parts but not able to think how to do this.
Pasting my code:

   
8 years ago
I think i had many such dreams but don't remember actually them right now and i think it's  "Lucid dreaming".
8 years ago
Congratulations for the new book!
I hope,i secure one of them
double kilometers = (100 * 1.609344);

Here, double is  a datatype (which is used to create a valid java statement)  and everything else except "double" in this case is an "expression"
I hope it helps,although i'm new at Java.
8 years ago