I am confused, I have to write a program that converts minutes to hours to days, how would i code this in java?

+1 vote
asked Sep 28 by Jayden Neifert Reeves (540 points)
I am confused, I have to write a program that converts minutes to hours to days, how would I code this in java?

2 Answers

+4 votes
answered Sep 29 by Peter Minarik (9,990 points)

Well, I think this is just a simple assignment, so you don't need to (or even shouldn't) use Java library functions for this.

You'd need the following steps:

  1. Create an integral variable to store the minutes. For simplicity, call it minutes.
  2. Ask the user to provide the minutes, store it in your variable minutes.
  3. You need to create another variable that can store integral numbers to store the hours and one another for the days. (You can use double as well for floating point numbers, a.k.a. to have fractions.) You can call them hours and days accordingly.
  4. Calculate the hours and days by dividing minutes with the appropriate numbers (how many minutes form an hour/day).
  5. Print the calculated hours and days to the user.

If you have never ever written any Java code, have a look at this or find your preferred tutorial.

Good luck!

commented Sep 30 by Jayden Neifert Reeves (540 points)
Thank you kind stranger!
0 votes
answered Oct 16 by Three Names Of Life (140 points)
60 minute = 1 hours

it means that 1 min = 1/60 hours

24 hours = 1 day

it means that 1 hour = 1/24 days

first take input time as minute then divide it (1/minute) for time in hours

then 1/hours for no of days
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...