An essential Julian Day Program
watch basic java videos herewww.youtube.com/user/trushntej
The term “Julian day” is used loosely to mean the day of the year, meaning a number from 1 to 365 or 366 (leap years). January 1 is 1 , January 2 is 2, December 31 is 365 (or 366 in leap years).
watch basic java videos here
www.youtube.com/user/trushntej
Write a program to accept a date in dd mm yyyy format, and print the Julian day.
import java.io.*;
public class JulianNumber
{
int d,m,y;
int n;
void input()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the date in dd mm yyyy format");
d=Integer.parseInt(br.readLine());
m=Integer.parseInt(br.readLine());
y=Integer.parseInt(br.readLine());
if(m<=12&&d<=31)
{
compute();
}
else
System.out.println("Invalid date");
}
void compute()
{
int arr[]={31,28,31,30,31,30,31,31,30,31,30,31};
if(y%4==0)
arr[1]=29;
for(int i=0;i<m-1;i++)
{
n+=arr[i];
}
n=n+d;
System.out.println("The Julian day is: "+n);
}
public static void main()throws IOException
{
JulianNumber obj=new JulianNumber();
obj.input();
}
}Output:
Enter the date in dd mm yyyy format
01
02
2020
The Julian day is :32
Take a look at some other java programs:
A Simple program: Sum of Boundary elements of a Matrix
Related Posts
Continue learning with these related articles

Logic Gates for ISC Class 11: Truth Tables, Universal Gates, Half and Full Adder
ISC Class 11 Computer Science notes on logic gates: AND, OR, NOT, NAND, NOR, XOR and XNOR with truth tables, why NAND and NOR are universal gates, and half adder and full adder circuits with their Boolean expressions.
Decimal to Binary Conversion in Java: 3 Programs with Examples
How to convert a decimal number to binary on paper and in Java: three programs (String, place value and Integer.toBinaryString), binary to decimal, a dry run and common mistakes.
Sum of First n Natural Numbers in Java (Loop and Formula)
Find the sum of the first n natural numbers in Java with a for loop, a while loop and the formula n(n + 1)/2, with a dry run and the sums of even numbers, odd numbers, squares and cubes.