Currently I'm learning java by myself and I have a long ways to come, but I've recently started a thing I wanted to make, but theres something wrong with it. I've copied a part of my code below which is inside the main. The objectnames are dutch, but those can be ignored mostly.
Basically what I want it to do is increase the "somnummer" by 1 after "som1" has been completed correctly, but currently thats not happening (checking it with the print at the end, is always 1).
Is it wrong of me to assume that it first completes the if function and everything in it and then move on to the somnummer++?
My code might seem like a bit of a mess, but I'm still very new to it. If possible I'd like the solution to be without too much new stuff, I'll reach that part sooner or later in my course ;)
Thanks in advance!
Scanner input = new Scanner(System.in);
int somnummer = 1;
if(somnummer == 1) {
System.out.println("");
System.out.println(som1);
do {
antwoord = input.nextInt();
if(antwoord != 5) {
System.out.println(fout);}}
while(antwoord != 5);
System.out.println(goed);
antwoord = 0;}
somnummer = somnummer++;
System.out.println(somnummer);
Aucun commentaire:
Enregistrer un commentaire