Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1.  
  2. public class CalendarSwitch {
  3.  
  4.     public static void main(String[] args) {
  5.         // TODO Auto-generated method stub
  6.         int year=1904;
  7.         String month="Februar";
  8.        
  9.         //Überprüfung: Schaltjahr
  10.         boolean sj = (year%4 == 0 && (year%100 != 0 || year%400 == 0));
  11.         //Überprüfung: Schaltjahr ENDE
  12.            
  13.         //Teil: Monat
  14.         if(month=="April"||month=="Juni"||month=="September"||month=="November"){
  15.             System.out.println("Dieser Monat hat 30 Tage");
  16.         }
  17.        
  18.         else if(month=="Januar"||month=="Maerz"||month=="Mai"||month=="Juli"||month=="August"||month=="Oktober"||month=="Dezember"){
  19.             System.out.println("Dieser Monat hat 31 Tage");
  20.         }
  21.         else if(month=="Februar"){
  22.             if(sj==false){
  23.                 System.out.println("Dieser Monat hat 28 Tage");
  24.             }
  25.             else{
  26.                 System.out.println("Dieser Monat hat 29 Tage");
  27.             }
  28.         }
  29.         else{
  30.             System.out.println("Ihre Eingabe ist falsch!");
  31.         }
  32.         //Teil: Monat ENDE
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement