Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.lang.Math;
- class Main {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int x;
- String y;
- y = null;
- x = 0;
- System.out.println("Please enter the date in number form.");
- System.out.println("Month:");
- int month = scan.nextInt();
- System.out.println("Day:");
- int day = scan.nextInt();
- System.out.println("Year:");
- int year = scan.nextInt();
- {if (year %4 != 0){
- x = 0;
- }if (month == 3){
- x = 59;
- y = "March";
- }if (month == 4){
- x = 90;
- y = "April";
- }if (month == 5){
- x = 120;
- y = "May";
- }if (month == 6){
- x = 151;
- y = "June";
- }if (month == 7){
- x = 181;
- y = "July";
- }if (month == 8){
- x = 212;
- y = "August";
- }if (month == 9){
- x = 243;
- y = "September";
- }if (month == 10){
- x = 273;
- y = "October";
- }if (month == 11){
- x = 304;
- y = "November";
- }if (month == 12){
- x = 334;
- y = "December";
- }if (month >= 12){
- x = 0;
- y = null;
- System.out.println("Please re-enter your date correctly in number form.");
- }
- else if (year%4 == 0){
- x = 0;
- }else if (month == 1){
- x = 0;
- y = "January";
- }if (month == 2){
- x = 31;
- y = "February";
- }else if (month == 3){
- x = 60;
- y = "March";
- }else if (month == 4){
- x = 91;
- y = "April";
- }else if (month == 5){
- x = 121;
- y = "May";
- }else if (month == 6){
- x = 152;
- y = "June";
- }else if (month == 7){
- x = 182;
- y = "July";
- }else if (month == 8){
- x = 213;
- y = "August";
- }else if (month == 9){
- x = 244;
- y = "September";
- }else if (month == 10){
- x = 274;
- y = "October";
- }else if (month == 11){
- x = 305;
- y = "November";
- }else if (month == 12){
- x = 335;
- y = "December";
- }else if (month >= 12){
- x = 0;
- y = null;
- System.out.println("Please re-enter your date correctly in number form.");
- }if (day == 1){
- System.out.println("Your date is in the month of "+ y +" and the "+ (x + day) +"st day of the year");
- }else{
- System.out.println("Your date is in the month of "+ y +" and the "+ (x + day) +"th day of the year");}
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement