SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class NestedForLoopNumbers {
  4.     public static void main(String[] args) {
  5.  
  6.         Scanner scan = new Scanner(System.in);
  7.         int number = scan.nextInt();
  8.         int firstDigit = number / 100;
  9.         int secondDigit = (number / 10) % 10;
  10.         int thirdDigit = number % 10;
  11.         int totalRows = firstDigit + secondDigit;
  12.         int totalCols = firstDigit + thirdDigit;
  13.  
  14.         for (int currentRow = 1; currentRow <= totalRows; currentRow++) {
  15.             for (int currentCol = 1; currentCol <= totalCols; currentCol++) {
  16.                 if (number % 5 == 0) {
  17.                     number -= firstDigit;
  18.                 } else if (number % 3 == 0) {
  19.                     number -= secondDigit;
  20.                 } else {
  21.                     number += thirdDigit;
  22.                 }
  23.                 System.out.print(number + " ");
  24.             }
  25.  
  26.         }
  27.     }
  28.  
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top