mercredi 7 novembre 2018

horoscope in java with if statement while knowing if the february of the year has 29th day or no

package horoscope;

import java.util.Scanner; public class Horoscope {

public static void main(String[] args) {
   Scanner h=new Scanner(System.in);
   int month;
   int day;
    System.out.println("enter the day");
    day=h.nextInt();
    System.out.println("enter the month");
    month=h.nextInt();
    if(month==3&& day>=21 && day<=31 || month==4 && day<=20 )
    {
        System.out.println("kawr");
    }
    else if(month ==4 && day>=21 && day<=30|| month==5 && day<=21){
    System.out.println("kalwe ga");   
    }
    else if(month == 5 && day>=22 && day<=31 || month == 6 && day<=21){
        System.out.println("dwana");  
}
    else  if (month == 6 && day>=22 && day<=30 || month == 7 && day<=22){
        System.out.println("qrzhal"); 
    }
    else if (month == 7 && day>=23 && day<=31 || month ==8 && day<=22){
        System.out.println("kalwe sheer");
    }
    else if ( month == 8 && day>=23 && day<=31|| month == 9 && day<=22)
    {
        System.out.println("farek");
    }
    else if(month == 9&& day>=23 && day<=30 || month == 10 && day>=22){
        System.out.println("tarazw");
    }
    else if (month == 10 && day>=23 && day<=31 || month == 11 && day<=21){
        System.out.println("dw pshk ");           
    }
    else if (month == 11 && day>=22 && day<=30|| month == 12 && day<=21){
        System.out.println("kawan");
    }
    else if ( month == 12 && day>=22 && day<=31 || month== 1 && day<=20){
        System.out.println("gesk"); 
    }
    else  if (month == 1 && day>=21 && day<=31 || month == 2 && day<=19)
    {
        System.out.println("satl");
    }
    else if(month == 2 && day>=20 && day<=28 || month==3 && day<=20)
    {
        System.out.println("nahang");
    }
    else {
        System.out.println("not available");
    }
}

}

so i have created a horoscope (sorry if you do not understand the print out text) and i wanna make it where if the year has the 29th day of February print the related text if not print out something like (not available)

Aucun commentaire:

Enregistrer un commentaire