1.

WAP in Java to accept the number of days and displays, it after converting them into no. of years, months and days.

Answer»

import java.io.*;

class days

{

public static void main ( ) throws IOException

{

in a, b, c, y, d; 

InputStreamReader read=new InputStreamReader(System.in);

BufferedReader in=new BufferedReader(read); System.out.printIn(“Enter the no. of days”); 

a = Integer.parseInt(in.readLine ( ));

y = a/365

b-a%365

c = b/30;

d = b%30;

System.out.printIn(“Years=”+y);

System.out.printIn(“Months=”+c); 

System.out.printIn(“Days=”+d); 

}} 



Discussion

No Comment Found

Related InterviewSolutions