In: Computer Science
Write a program that accepts a number of minutes and converts it both to hours and days. For example, 6000 minutes is 100.0 hours or 4.166666666666667 days.
(I currently have what is below)
import java.util.Scanner; public class MinutesConversion { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int numOfMinutes = sc.nextInt(); double hour = numOfMinutes/60.00; double days = (hour/24); System.out.println(numOfMinutes + " minutes is " + hour + " hours or " + days + " days."); } }
The test values are 6000 and 1578. My program gets the correct answer for 6000 but not 1578? Any advice?
import java.util.Scanner;
public class MinutesConversion{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int numOfMinutes = sc.nextInt();
double hour = numOfMinutes/60.00;//converting to hours //since each
hour has 60 mins
double days = (hour/24);//converting to days//since ecah day has 24
hrs
//the logic is fine
//and it is giving correct output for 1578 also
System.out.println(numOfMinutes + " minutes is " + hour + " hours
or " + days + " days.");
}
}
output: