Hallo, ich habe morgen ein Nachgespräch in einer Firma für meinen Ausbildungsplatz und ich habe mich in der Zwischenzeit für diesen viel mit Java auseinandergesetzt und heute ein erstes Programm geschrieben. Vor wenigen Stunden lief es, ich schaltete den Computer aus, hatte zuvor alles ordnungsgemäß gesichert, ich schalte den Rechner ein, öffne Eclipse, nehme einige kleine Änderungen vor (Einige Zeilen Code hinzugefügt), dann startete ich das Programm und plötzlich geht ab einem gewissen Punkt gar nichts mehr, wo ich gar nicht mal weiter geschrieben habe. Zunächst hatte ich das Problem, dass ich keinen Input geben konnte, dann, als ich das gelöst habe, kam nach meinem Input keine Reaktion mehr. So wie der Code da steht lief vor wenigen Stunden noch und nun Pustekuchen. Ich würde mich über Hilfe sehr freuen, da ich nun bereits mindestens eine Stunde versuche den Fehler zu finden.
Ich habe die fehlerhaften Stellen mit Randnotizen markiert (// Randnotiz) ich hoffe, dass das hilfreich ist. Sind die Zeilen 25 und 52. Witzigerweise.
Vielen Dank.
Ich habe die fehlerhaften Stellen mit Randnotizen markiert (// Randnotiz) ich hoffe, dass das hilfreich ist. Sind die Zeilen 25 und 52. Witzigerweise.
Vielen Dank.
Java:
import java.util.Scanner;
class Test{
public static void main(String args[]){
Scanner tests = new Scanner(System.in);
System.out.println("What's your name?");
String Name = tests.nextLine();
if (Name.equals("")){
System.out.print("Please tell me your name.");
System.out.println("What's your name?");
}else{
System.out.println("Hello " + Name + ". Press Enter.");
}
String Gender = tests.nextLine();
System.out.println("Are you male, or female?");
Gender = tests.nextLine();
switch (Gender) {
case "male":
System.out.println("Nice. Do you like football?");
String Football = tests.nextLine();
break;
case "Male":
System.out.println("Nice. Do you like football?");
Football = tests.nextLine();
switch (Football) { // ab hier scheitert das Programm, ich kann wieder Input geben, aber zurück kommt nichts mehr
case "yes":
System.out.println("Nice. Me not. But I am still happy for you.");
break;
case "Yes":
System.out.println("Nice. Me not. But I am still happy for you.");
break;
case "no":
System.out.println("Nice. Me neither. So let's go on programming together. Would you like to?");
break;
case "No":
System.out.println("Nice. Me neither. So let's go on programming together. Would you like to?");
break;
}
String Programming = tests.nextLine();
switch (Programming) {
case "yes":
System.out.println("Wonderful. I am sure we will have much fun together! Tell me now, do you know what an Integer is?");
break;
case "Yes":
System.out.println("Wonderful. I am sure we will have much fun together! Tell me now, do you know what an Integer is?");
break;
case "no":
System.out.println("Well this is sad. Java is a nice language, you should give it a try one day. See you then, " + Name + ". Have a great day.");
}
break;
case "female":
System.out.println("Nice. How about giving me your phone number?"); //ebenso hier, es wird kein Input angenommen
break;
case "Female":
System.out.println("Nice. How about giving me your phone number?");
String Number = tests.nextLine();
switch (Number) {
case ("yes"):
System.out.println("Thank you very much. But I sadly can't write it down now, so maybe another time.");
break;
case ("Yes"):
System.out.println("Thank you very much. But I sadly can't write it down now, so maybe another time.");
break;
case "no":
System.out.println("That's sad, although I am so nice? Do you have a boyfriend?");
break;
case "No":
System.out.println("That's sad, although I am so nice? Do you have a boyfriend?");
String Boyfriend = tests.nextLine();
switch (Boyfriend) {
case ("yes"):
System.out.println("Okay, then I wish you a good time with him. :) Would you like to program together with me?");
break;
case ("Yes"):
System.out.println("Okay, then I wish you a good time with him. :) Would you like to program together with me?");
break;
case ("no"):
System.out.println("Oh, okay. I wish you good luck finding one, because I think you are really pretty. Would you like to program together with me?");
break;
case ("No"):
System.out.println("Oh, okay. I wish you good luck finding one, because I think you are really pretty. Would you like to program together with me?");
}
}
}
}
}