package com.company;
import java.util.Scanner;
public class AdditionQuiz {
public static void main(String[] args){
int number1 = (int)(System.currentTimeMillis() % 10);
int number2 = (int)(System.currentTimeMillis() / 7 % 10);
Scanner input = new Scanner(System.in);
System.out.println("What is " + number1 + " + " + number2 + "? ");
int answer = input.nextInt();
System.out.println(number1 + " + " + number2 + " = " + answer + " is " + (number1 + number2 == answer));
}
}
/Users/wanshuai/Library/Java/JavaVirtualMachines/openjdk-15.0.1/Contents/Home/bin/java -javaagent:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar=49160:/Applications/IntelliJ IDEA CE.app/Contents/bin -Dfile.encoding=UTF-8 -classpath /Users/wanshuai/IdeaProjects/untitled/out/production/untitled com.company.AdditionQuiz
What is 9 + 1?
10
9 + 1 = 10 is true
Process finished with exit code 0
package com.company; import java.util.Scanner; public class SimpleIfDemo { public static void main(String[] args){ Scanner input = new Scanner(System.in); System.out.println("Enter an integer: "); int number = input.nextInt(); if (number % 5 == 0){ System.out.println("HiFive"); } if (number % 2 == 0){ System.out.println("HiEven"); } } }
/Users/wanshuai/Library/Java/JavaVirtualMachines/openjdk-15.0.1/Contents/Home/bin/java -javaagent:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar=49441:/Applications/IntelliJ IDEA CE.app/Contents/bin -Dfile.encoding=UTF-8 -classpath /Users/wanshuai/IdeaProjects/untitled/out/production/untitled com.company.SimpleIfDemo
Enter an integer:
30
HiFive
HiEven
Process finished with exit code 0