Java program to convert given no. of days into months and days

1
2
3
4
5
6
7
8
9
10
11
12
13
/* Write a program to convert given no. of days into months and days.
   (Assume that each month is of 30 days)
   Example :
   Input - 69
   Output - 69 days = 2 Month and 9 days */
class DayMonthDemo{
	public static void main(String args[]){
		int num = Integer.parseInt(args[0]);
		int days = num%30;
		int month = num/30;
		System.out.println(num+" days = "+month+" Month and "+days+" days");
	}
}

2 Responses to “Java program to convert given no. of days into months and days”

  1. Jayson

    Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 0
    at converter.Converter.main(Converter.java:7)
    Java Result: 1

    Reply
  2. Andrew Rogger

    After reading the post I have got to know about the common problems that cause the email to stay in the outbox. The main cause is the internet connectivity. Visit error code 43 mac to know more.

    Reply

Leave a Reply