Advertisement
clrdz

Untitled

Mar 25th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. package de.ostfalia.gdp.ss19.s2;
  2.  
  3. import java.util.Scanner;
  4. /**
  5. * Serie2
  6. *
  7. * @author Clarissa
  8. */
  9. public class Schaltjahr {
  10.  
  11. /**
  12. * main method
  13. *
  14. * @param args
  15. */
  16. public static void main(String[] args) {
  17. // TODO Auto-generated method stub
  18.  
  19. Scanner scanner = new Scanner(System.in);
  20. System.out.println("Geben Sie die Jahreszahl ein:");
  21. int schaltjahr = scanner.nextInt();
  22. boolean isSchaltjahr;
  23.  
  24. if ((schaltjahr % 4 == 0) && (schaltjahr % 100 != 0)) {
  25. isSchaltjahr = true;
  26. System.out.println("Eingabe: " + schaltjahr);
  27. System.out.println(isSchaltjahr);
  28.  
  29. } else if ((schaltjahr % 100 == 0 && schaltjahr % 400 != 0)) {
  30. isSchaltjahr = false;
  31. System.out.println("Eingabe: " + schaltjahr);
  32. System.out.println(isSchaltjahr);
  33.  
  34. } else if (schaltjahr % 400 == 0) {
  35. isSchaltjahr = true;
  36. System.out.println("Eingabe: " + schaltjahr);
  37. System.out.println("Schaltjahr = " + isSchaltjahr);
  38.  
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement