TheBulgarianWolf

Numbers

Mar 15th, 2020
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Main
  3. {
  4.     public static void main(String[] args) {
  5.         Scanner sc = new Scanner(System.in);
  6.         System.out.print("Enter your number here: ");
  7.         int number = Integer.parseInt(sc.nextLine());
  8.         int thirdDigit = number%10;
  9.         int number2 = number/10;
  10.         int secondDigit = number2%10;
  11.         int firstDigit = number/100;
  12.         int n = firstDigit + secondDigit;
  13.         int m = firstDigit + thirdDigit;
  14.         if(number % 5 == 0){
  15.             System.out.println(number-firstDigit);
  16.         }
  17.         else if(number % 3 == 0){
  18.             System.out.println(number-secondDigit);
  19.         }
  20.         else{
  21.             for(int row = 1;row<=n;row++){
  22.                 for(int col = 1;col<=m;col++){
  23.                     number += thirdDigit;
  24.                     System.out.print(number + " ");
  25.                 }
  26.                 System.out.println();
  27.             }
  28.         }
  29.        
  30.     }
  31. }
Add Comment
Please, Sign In to add comment