Write a program to convert given number of days into months and days.(Assume that each month is of 30 days).
Input:- 46
Output:- 46 days = 1 Month and 16 days
Sample Program:-
/**
*
*/
/**
* @author Dixit
*
*/
public class DayMonthProgram {
/**
* @param args
*/
public static void main(String[] args) {
int num = 46;
int days = num % 30;
int month = num / 30;
System.out.println(num + " days = " + month + " Month and " + days
+ " days");
}
}
Output
46 days = 1 Month and 16 days
Enjoy Programming.
No comments:
Post a Comment