import java.util.*; public class SimpleMathGame { public static void main(String[] args) { Scanner in=new Scanner(System.in); Random g=new Random(); System.out.println("Hi, I'm going to ask a simple math question. Can you get it right?"); int v1, v2, v3, op, answer; v1=g.nextInt(20)+1; v2=g.nextInt(40)-20; op=g.nextInt(4); if(op==0) { v3=v1+v2; System.out.print("The problem is: " + v1 + " + " + v2 + " = ? "); } else if(op==1) { v3=v1-v2; System.out.print("The problem is: " + v1 + " - " + v2 + " = ? "); } else if(op==2) { v3=v1*v2; System.out.print("The problem is: " + v1 + " * " + v2 + " = ? "); } else { v3=v1/v2; System.out.print("The problem is: " + v1 + " / " + v2 + " = ? "); } answer=in.nextInt(); if(answer==v3) System.out.println("Congratulations, you got it right!"); else System.out.println("Sorry, the answer is " + v3); } }