Advertisement
YavorGrancharov

TriangleOfDollars

Feb 12th, 2017
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TriangleOfDollars {
  4.     public static void main(String[] args) {
  5.         Scanner console = new Scanner(System.in);
  6.         int n = Integer.parseInt(console.nextLine());
  7.         for (int i = 1; i <= n; i++) {
  8.             System.out.println(repeatStr("$" + " ", i));
  9.         }
  10.     }
  11.  
  12.     static String repeatStr(String str, int count) {
  13.         StringBuilder repeated = new StringBuilder();
  14.         for (int i = 0; i < count; i++) {
  15.             repeated.append(str);
  16.         }
  17.         return repeated.toString();
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement