I'm sure there's an easier way to do this, but I was trying to make a very primitive java program that would move on if the answer was correct and would terminate if it wasn't. It works and gets to the end if the user inputs the answers correctly, but it also does that even if he doesn't answer correctly(besides the first question, which takes two inputs to proceed for some reason). It's in my native language but you should get the gist of it.
package summaries; import java.util.Scanner; public class Akvile { public static void main(String[] args) { int answer=3, answer2=62 ,answer3=1964; Scanner print = new Scanner(System.in); System.out.println("Labas."); System.out.println("Kiek bus 2+2/2 ?"); int ans1 = print.nextInt(); if (ans1 == answer) { System.out.println("Teisingai. Sudek Roko ir Akviles metus ir padvigubink. Kiek bus?"); } int ans2=print.nextInt(); if (ans2 == answer2 ){ System.out.println("Teisingai! Liko paskutinis klausimas:"); } System.out.println("Kelintais metais yra gimusi mama?"); int ans3 = print.nextInt(); if (answer3 == 1964){ System.out.println("Deja...Bet atsakei tesingai!!! Laimejai zaidima. Stai tavo prizas:"); System.out.println(":)"); } else{ System.exit(1); }