Write a java program to convert numbers into years, weeks and days

Write a java program to convert numbers into years, weeks and days. This Java program converts a given number of days to years, weeks, and days. As an input, choose any integer number. Then, to calculate the number of years, we divide the input by 365. Then we divide by 7 to get the number of weeks using the modulus operation. To get the number of days, we use modulo operation.

import java.util.Scanner;
public class Main
public static void main(String args[])
int m, year, week, day;
Scanner s = new Scanner(System.in);
System.out.print("Enter the numbers");
m = s.nextInt();
year = m / 365;
m = m % 365;
System.out.println("No of years"+year);
week = m / 7;
m = m % 7;
System.out.println("No of weeks:"+week);
day = m;
System.out.println("No of days:"+day);



Enter the numbers567
No of years1
No of weeks:28
No of days:6

Why do we have 12 months and when it is created

The requirement for 12 months in a year and the addition of a leap year to coordinate with the seasons was explained by Julius Caesar’s astronomers. Because these months were named after Roman leaders, they were given 31 days to signify their importance. Julius Caesar ordered a calendar with twelve months based on a solar year in 45 B.C. This calendar used a three-year cycle of 365 days, followed by a 366-day year (leap year). The “Julian Calendar” also shifted the start of the year from March 1 to January 1 when it was originally introduced.

What is util scanner in java program

Scanner is a class in the Java util package that is used to get input of primitive kinds such as int, double, and strings. It’s the simplest way to read input in a Java program, but it’s inefficient if you need an input method for situations where time is a factor, such as competitive programming.