fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // This will get the input of the A and X variables from the user via Scanner
  13. Scanner userInput = new Scanner(System.in);
  14. System.out.println("Please enter the value of A: ");
  15. int A = userInput.nextInt();
  16. System.out.println("Please enter the value of X: ");
  17. int X = userInput.nextInt();
  18.  
  19. //This is the For Loop of the multiples of A until X
  20. for (int b=1; b<=X;++b) {
  21. System.out.println(A + " * " + b + " = " + A * b);
  22. }
  23. //This is the For Loop of the multiples of A + 1 until 2X
  24. for (int c=1; c<=X*2;++c) {
  25. //System.out.println(c);
  26. System.out.println("(" + A + " * " + c + ") +1" + " = " + ((A * c)+1));
  27. }
  28. //This is the For Loop of the multiples of A+2 until 3X
  29. for (int d=1; d<=X*3;++d) {
  30. System.out.println("(" + A + " * " + d + ") +2" + " = " + ((A * d)+2));
  31. }
  32. //This closes the Scanner
  33. userInput.close();
  34. }
  35. }
Success #stdin #stdout 0.19s 54936KB
stdin
1
4
stdout
Please enter the value of A: 
Please enter the value of X: 
1 * 1 = 1
1 * 2 = 2
1 * 3 = 3
1 * 4 = 4
(1 * 1) +1 = 2
(1 * 2) +1 = 3
(1 * 3) +1 = 4
(1 * 4) +1 = 5
(1 * 5) +1 = 6
(1 * 6) +1 = 7
(1 * 7) +1 = 8
(1 * 8) +1 = 9
(1 * 1) +2 = 3
(1 * 2) +2 = 4
(1 * 3) +2 = 5
(1 * 4) +2 = 6
(1 * 5) +2 = 7
(1 * 6) +2 = 8
(1 * 7) +2 = 9
(1 * 8) +2 = 10
(1 * 9) +2 = 11
(1 * 10) +2 = 12
(1 * 11) +2 = 13
(1 * 12) +2 = 14