Warum geht die Switch hier nicht im Code ?
Archiviert 3 years ago
C
chiba5496
```java
package day2;
import java.util.Random;
import java.util.Scanner;
public class AufgabeWuerfel {
public static void main(String[] args) {
System.out.println("Geben Sie ihren Einsatz ein.");
einsatz();
System.out.println("Ihr Einsatz beträgt: "+einsatz());
wurfelges();
System.out.println("Ihre Würfel haben: "+ wurfelges() + " gewürfelt.");
int wurfelzahl = wurfelges();
switch (wurfelzahl){
case 1:
boolean keineinsatz =wurfelzahl <7;
System.out.println("Du hast nichts gewonnen");
break;
case 2:
boolean einfacheinsatz = wurfelzahl < 10 && wurfelzahl >6;
double einsatz1 = einsatz();
System.out.println("Du hast deinen "+ einsatz() + "gewonnen");
break;
case 3:
boolean zweifacheinsatz = wurfelzahl == 10;
double einsatz2 = einsatz()*2;
System.out.println("Du hast: "+ einsatz2 + "gewonnen");
break;
case 4:
boolean dreifacheinsatz = wurfelzahl == 11;
double einsatz3 = einsatz()*3;
System.out.println("Du hast: "+ einsatz3 + "gewonnen");
break;
case 5:
boolean vierfacheinsatz = wurfelzahl ==12;
double einsatz4 = einsatz()*4;
System.out.println("Du hast : "+ einsatz4 + "gewonnen");
break;
}
}
public static double einsatz (){
Scanner sc = new Scanner(System.in);
double eingabe = sc.nextDouble();
sc.nextLine();
return eingabe;
}
public static int wurfelges (){
Random rnd = new Random();
int wurfel1 = rnd.nextInt(6)+1;
int wurfel2 = rnd.nextInt(6)+1;
int wurfelgesamt = wurfel1 + wurfel2;
return wurfelgesamt;
}
```
