For those of you where your place don't have four seasons like europe and any other countries have, don't be sad to determine which date of month is the season would be. I'd received this assignment from my lecturer to determine the season according to the date and month.
package calender; import java.util.*; public class Calender { public static void main(String[] args) { int date, month; //declare the variable //declare the Scanner so that user can store value to memory Scanner input = new Scanner(System.in); //Asking user to enter the date System.out.print("Please enter date: "); date = input.nextInt(); //Asking user to enter month System.out.print("Please enter month: "); month = input.nextInt(); //Condition to determine month not more than 13 and day not more than 32 if (month >= 13 || month < 1 || date > 31 || date <= 0) { System.out.println("Please enter a valid date and month"); } else { System.out.print("On "+getMonth(month)+", "+date+" the season "); System.out.println("is: "+season(date,month)); } }//end main method public static String getMonth(int z) //Task3 Addition { //Switching number to string type switch(z) { case 1: return "January"; case 2: return "February"; case 3: return "March"; case 4: return "April"; case 5: return "May"; case 6: return "June"; case 7: return "July"; case 8: return "August"; case 9: return "September"; case 10: return "October"; case 11: return "November"; case 12: return "December"; default: return "No Month"; } }//end getMonth method public static String season(int x, int y) //task2 { String season = null; //Initializing season before statement //The condition when the season start if (((y == 12)&&(x>=16))||((y<=3)&&(x<=15))){ season = "Winter"; } else if (((y >= 3)&&(x>=16))||((y<=6)&&(x<=15))){ season = "Spring"; } else if (((y >= 6)&&(x>=16))||((y<=9)&&(x<=15))){ season = "Summer"; } else if (((y >= 9)&&(x>=16))||((y<=12)&&(x<=15))){ season = "Fall"; } return season; } //end season method }//end class
This specific specific workforce connected with professionals functions round the clock to make sure basic safety and well-timed shipping and delivery of this merchandise.
ReplyDeleteClick Here:
packers and movers pune
packers and movers in pune
movers and packers pune
movers and packers in pune
brother...if y=2 & x=23..then program should print winter..but i could not get your code.
ReplyDeletewould you plz clarify???