Advertisement
xboy90

Flag

Feb 20th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. package CodeAcademy_6_Arrays_Functions_And_OOP;
  2.  
  3. import java.util.Arrays;
  4. import java.util.Scanner;
  5.  
  6. public class FlagDemo
  7. {
  8.   public static void main(String[] args)
  9.   {
  10.     final String WHITE = "\033[39m";
  11.     final String GREEN = "\033[31m";
  12.     final String RED = "\033[32m";
  13.  
  14.     Scanner scanner = new Scanner(System.in);
  15.     System.out.println("Enter the size of the flag : ");
  16.  
  17.     int size = scanner.nextInt();
  18.     char[] row = new char[size];
  19.     Arrays.fill(row, '\u2588');
  20.  
  21.     for (int i = 0; i < 3; i++) {
  22.  
  23.       String colour = new String(row);
  24.  
  25.       if (i == 0) {
  26.         System.out.printf("%s%s %n", WHITE, colour);
  27.       }
  28.       else if (i == 1) {
  29.         System.out.printf("%s%s %n", GREEN, colour);
  30.       }
  31.       else {
  32.         System.out.printf("%s%s %n", RED, colour);
  33.       }
  34.  
  35.     }
  36.  
  37.   }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement