Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

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

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

3 Answers

+5 votes
answered Sep 29, 2020 by Peter Minarik (84,720 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, 2020 by Jayden Neifert Reeves (530 points)
Thank you kind stranger!
0 votes
answered Oct 16, 2020 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
+1 vote
answered Feb 16, 2021 by piyush kumar singh (160 points)
import java.util.Scanner;
   public class Main {
       public static void main(String[] args) {
           Scanner sc = new Scanner(System.in);

           System.out.println("enter the minutes:");
           double minutes = sc.nextDouble() ;

           double hours =  minutes / 60;
           System.out.println(" total no of hours are " + hours);

           double days = hours/24;
           System.out.println("total no of days are :" + 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.
...