convert minutes into a number of years and days.Write a Java program to convert minutes into a number of years and days. Constraints:N/AExample:InputThe number of minutes: 3456789Output:6years 210 days
Question
convert minutes into a number of years and days.Write a Java program to convert minutes into a number of years and days. Constraints:N/AExample:InputThe number of minutes: 3456789Output:6years 210 days
Solution
Here is a simple Java program that converts minutes into years and days:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter the number of minutes: ");
int minutes = input.nextInt();
// 1 year = 365 days, 1 day = 24 hours, 1 hour = 60 minutes
// So, 1 year = 365 * 24 * 60 minutes
int year = minutes / (365 * 24 * 60);
int remainingMinutes = minutes % (365 * 24 * 60);
// 1 day = 24 hours, 1 hour = 60 minutes
// So, 1 day = 24 * 60 minutes
int day = remainingMinutes / (24 * 60);
System.out.println(minutes + " minutes is approximately " + year + " years and " + day + " days");
}
}
This program first asks the user to input the number of minutes. It then calculates the number of years by dividing the total minutes by the number of minutes in a year (365 days * 24 hours * 60 minutes). The remaining minutes are calculated using the modulus operator. Finally, it calculates the number of days by dividing the remaining minutes by the number of minutes in a day (24 hours * 60 minutes). The result is then printed out.
Similar Questions
Convert hours to the number of days to the thousandth place. 48.5 hours = days.
Write a Python program that converts seconds into days, hours, minutes, and seconds.
Create a Time class and initialize it with hours and minutes.1. Make a method addTime which should take two time object and add them. E.g.- (2 hour and 50 min)+(1 hr and 20 min) is (4 hr and 10 min)2. Make a method displayTime which should print the time.3. Make a method DisplayMinute which should display the total minutes in the Time. E.g.- (1 hr 2 min) should display 62 minute.
Write this ratio as a fraction in simplest form without any units.35 days to 6 weeksYou can use the table below to help convert the units.1 minute =60 seconds1 hour =60 minutes1 day =24 hours1 week =7 days
You spend 217 minutes playing games on your phone each day. If you do this for a whole year (365 days), how many entire days of your life did you spend playing games?Hint: First multiply 217 x 365 to get the total number of minutes that you spent playing games, then convert the minutes to days.60 minutes = 1 hour24 hours = 1 dayRound your answer to the nearest tenth.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.