Addition and subtraction
Our 6 year old son is working on addition and subtraction.
public class Main {
public static void main(String[] args) {
Math.Math();
}
}
import java.util.Random;
public class Math {
public static void Math() {
//Division with Divisor as number
System.out.println();
System.out.println();
Random rand = new Random();
int high;
int low;
for (int x = 1; x < 11; x++) {
for (int y = 1; y < 3; y++) {
int rand_x = rand.nextInt(19) + 1;
int rand_y = rand.nextInt(19) + 1;
if (rand_x >= rand_y) {
high = rand_x;
low = rand_y;
} else {
high = rand_y;
low = rand_x;
}
System.out.printf("___" + " " + " + " + " " + low + " = " + high + " ");
rand_x = rand.nextInt(19) + 1;
rand_y = rand.nextInt(19) + 1;
if (rand_x >= rand_y) {
high = rand_x;
low = rand_y;
} else {
high = rand_y;
low = rand_x;
}
System.out.printf(high + " - " + " ___ " + " = " + low + " ");
}
System.out.println();
System.out.println();
}
}
}
C:\Users\Win10x64i7\.jdks\openjdk-23.0.1\bin\java.exe "-javaagent:D:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2024.2.4\lib\idea_rt.jar=60127:D:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2024.2.4\bin" -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath C:\Users\Win10x64i7\IdeaProjects\Kieran\out\production\Kieran Main
___ + 13 = 15 16 - ___ = 7 ___ + 3 = 17 14 - ___ = 1
___ + 5 = 5 8 - ___ = 3 ___ + 1 = 6 13 - ___ = 1
___ + 3 = 9 17 - ___ = 5 ___ + 9 = 12 17 - ___ = 3
___ + 6 = 16 17 - ___ = 9 ___ + 2 = 15 16 - ___ = 13
___ + 15 = 19 7 - ___ = 5 ___ + 6 = 6 18 - ___ = 5
___ + 11 = 13 18 - ___ = 13 ___ + 9 = 19 15 - ___ = 10
___ + 12 = 15 5 - ___ = 3 ___ + 3 = 4 6 - ___ = 5
___ + 8 = 13 18 - ___ = 10 ___ + 5 = 18 14 - ___ = 1
___ + 13 = 14 6 - ___ = 2 ___ + 14 = 14 8 - ___ = 2
___ + 2 = 5 17 - ___ = 1 ___ + 7 = 16 18 - ___ = 15
Process finished with exit code 0