Write a program in Java to accept the 5 digits day value (using Function argument
of main ( ) method) & convert the day value in year, month week and day form.
Display the result with proper message.
Answers
Answered by
5
Answer:
import java.util.Scanner;
public class Year_Week_Day
{
public static void main(String args[])
{
int m, year, week, day;
Scanner s = new Scanner(System.in);
System.out.print("Enter the number of days:");
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);
}
}
Output:
$ javac Year_Week_Day.java
$ java Year_Week_Day
Enter the number of days:756
No. of years:2
No. of weeks:3
No. of days:5
Answered by
1
Answer:
sorry for bad handwriting
this program is checked by my computer teacher.
thank you have a great day.
Attachments:
Similar questions
Biology,
4 months ago
History,
9 months ago
English,
9 months ago
Science,
1 year ago
Political Science,
1 year ago