Write a Java program to create a class named Convert to perform the following tasks: (i) Accept the number of days. (Use Scanner Class) (ii) Convert the number of days and display the number of years, months, and days. Example: Input => Number of days: 397 Output => Number of years: 1 Number of months: 1 Number of days: 2 [Hint: Assume number of days in a year as 365 and days in month as 30]
Answers
Answered by
8
""" ❤️ Answer ❤️ """
import java.util.Scanner;
public class KboatDayConversion
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter days: ");
int days = in.nextInt();
int years = days / 365;
days = days - (365 * years);
int months = days / 30;
int d = days - (months * 30);
System.out.println(years + " Years " + months + " Months " + d + " Days");
}
}
Similar questions
Math,
15 days ago
Psychology,
15 days ago
Geography,
15 days ago
English,
1 month ago
Social Sciences,
1 month ago
Science,
9 months ago
English,
9 months ago
Math,
9 months ago