Advertisement
CR7CR7

reverseTableMultiplication

Dec 16th, 2023
1,057
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  class ReverseMultiplicationTable {
  4.     public static void main(String[] args) {
  5.         Scanner input = new Scanner(System.in);
  6.        
  7.         String numberString = input.nextLine();
  8.        
  9.                 if (numberString.length() == 3 && !numberString.contains("-") && !numberString.contains("0")) {
  10.          
  11.             char digit3 = numberString.charAt(0);
  12.             char digit2 = numberString.charAt(1);
  13.             char digit1 = numberString.charAt(2);
  14.            
  15.            
  16.             for (int i = 1; i <= Integer.parseInt(String.valueOf(digit3)); i++) {
  17.                 for (int j = 1; j <= Integer.parseInt(String.valueOf(digit2)); j++) {
  18.                     for (int k = 1; k <= Integer.parseInt(String.valueOf(digit1)); k++) {
  19.                         int product = i * j * k;
  20.                         System.out.println(i + " * " + j + " * " + k + " = " + product);
  21.                     }
  22.                 }
  23.             }
  24.         } else {
  25.             System.out.println("invalid input number!");
  26.         }
  27.     }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement