Write a java program to enter total number of days and convert it into years, months, week and remaining days. Where 1year= 300 days and 1 month= 20 days 1 week= 7 days.
Plss help....
Share
Write a java program to enter total number of days and convert it into years, months, week and remaining days. Where 1year= 300 days and 1 month= 20 days 1 week= 7 days.
Plss help....
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Verified answer
Answer:
The java code of the above solution is:
Explanation:
/**
* Java program to convert days to years weeks and days.
*/
import java.util.Scanner;
public class DaysConverter {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
/* Input number of days from user */
System.out.print("Enter days: ");
int days = in.nextInt();
/* Year, weeks and days conversion */
int years = (days / 365);
int weeks = (days % 365) / 7;
days = (days % 365) % 7;
/* Print total years, weeks and remaining days in given days */
System.out.println("Year/s = " + years);
System.out.println("Week/s = " + weeks);
System.out.println("Day/s = " + days);
}
}