Need this program in Java Develop using C or Java language t

Need this program in Java

Develop (using C++ or Java language) the software application described below.

Write a program that prints the day number of the year, given the date is in the form month-day-year.

For example, if the input is 1-1-09, the day number is 1; if the input is 12-25-09, the day number is 359. The program should check for a leap year. A year is a leap year if it is divisible by 4 but not divisible by 100.

For example, 1992 and 2008 are divisible by 4 but not by 100. A year that is divisible by 100 is a leap year if it is also divisible by 400.

For example 1600 and 2000 are divisible by 400, so they are leap years. However, 1800 is not a leap year because 1800 is not divisible by 400.

Solution

Here is the code for your guven problem, just copy paste and enjoy.

import java.util.*;
import java.lang.*;
import java.io.*;
class dayOfTheYear
{
   public static void main (String[] args)
   {
       System.out.println(\"Please input the date in MM DD YYYY format: \");
       Scanner in=new Scanner(System.in);
       int MM=in.nextInt();
       int DD=in.nextInt();
       int YYYY=in.nextInt();
       MM--;
  
   int DOY;
   if(MM%2!=0)
{
   if(MM<=7)
   DOY=31*MM;
   else
   DOY=30*MM;
  
}
else
{
   if(MM==2)
  
   DOY=28*MM;
  
else
{
   if(MM>=8)
   DOY=31*MM;
   else
   DOY=30*MM;
}

}
if((YYYY % 400 == 0) || (YYYY % 4 == 0) && (YYYY % 100 != 0)){
if(MM>=1)
DOY+=DD+1;
else
DOY+=DD;
}
else
DOY+=DD;
  
System.out.println(\"Today is \"+DOY+\"th day of the year\");
  
}

}

if you like this answer, please give a thumbs up and if you have some doubt just ask in the comment section below. I will try to help. Cheers

Need this program in Java Develop (using C++ or Java language) the software application described below. Write a program that prints the day number of the year,
Need this program in Java Develop (using C++ or Java language) the software application described below. Write a program that prints the day number of the year,

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site