Advertisement
eranseg

Reverse Right Triangle

Jul 28th, 2019
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ReverseTriangleToRight {
  4.     public static void main(String[] args) {
  5.         Scanner sc = new Scanner(System.in);
  6.         System.out.println("Please enter the size of the triangle base: ");
  7.         int base = sc.nextInt();
  8.         for(int i = base; i > 0; i--) { // Each iteration draws a different line
  9.             for(int j = 0; j < base - i; j++) { // A loop for printing the spaces in a row
  10.                 System.out.print(" ");
  11.             }
  12.             for(int j = 0; j < i; j++) { // A loop for printing the astrixes in a row
  13.                 System.out.print("*");
  14.             }
  15.             System.out.println();
  16.         }
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement