rainy 1234
rainy 1234
JCHJava Community | Help. Code. Learn.
Created by blue on 9/14/2024 in #java-help
Why do I need the abs method
package de.codegym.task.task04.task0413; /* Wochentag / import java.io.; import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws Exception {
//schreib hier deinen Code

BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
int a = input.read();// read a number from keyboard

//Scanner numberkind = new Scanner(System.in);
//int a = numberkind.nextInt();


if (a ==1 )
System.out.println("Montag");
else if (a == 2 )
System.out.println("Dienstag");
else if (a == 3 )
System.out.println("Mittwoch");
else if (a == 4 )
System.out.println("Donnerstag");
else if (a == 5 )
System.out.println("Freitag");
else if (a ==6 )
System.out.println("Samstag");
else if (a == 7 )
System.out.println("Sonntag");

else if ( a > 7 || a < 1) //condition always true
// since if reached only option bigger or less
// then given intervall
//=> just else also enough
System.out.println("Diesen Wochentag gibt es nicht");

}
}
public class Solution {
public static void main(String[] args) throws Exception {
//schreib hier deinen Code

BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
int a = input.read();// read a number from keyboard

//Scanner numberkind = new Scanner(System.in);
//int a = numberkind.nextInt();


if (a ==1 )
System.out.println("Montag");
else if (a == 2 )
System.out.println("Dienstag");
else if (a == 3 )
System.out.println("Mittwoch");
else if (a == 4 )
System.out.println("Donnerstag");
else if (a == 5 )
System.out.println("Freitag");
else if (a ==6 )
System.out.println("Samstag");
else if (a == 7 )
System.out.println("Sonntag");

else if ( a > 7 || a < 1) //condition always true
// since if reached only option bigger or less
// then given intervall
//=> just else also enough
System.out.println("Diesen Wochentag gibt es nicht");

}
}
40 replies