Guest User

Untitled

a guest
Feb 19th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TriangleVariant
  4. {
  5.     public static void main(String[] args)
  6.     {
  7.  
  8.         String lnBreak = System.getProperty("line.separator"); // cross platform next line
  9.  
  10.         System.out.println("How big should the triangle be?");
  11.  
  12.         Scanner input = new Scanner(System.in); // length of the max value
  13.         int size = input.nextInt();
  14.  
  15.         for(int i = 0; i != (size + 1); i++)
  16.         {
  17.             for(int x = 0; x != i; x++)
  18.             {
  19.                 System.out.print("*");
  20.             }
  21.             System.out.print(lnBreak);
  22.         }
  23.         for(int i = size; i != 0; i--)
  24.         {  
  25.             for(int x = (i - 1); x != 0; x--)
  26.             {
  27.                 System.out.print("*");
  28.             }
  29.             System.out.print(lnBreak);
  30.         }
  31.            
  32.     }
  33. }
Add Comment
Please, Sign In to add comment