Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SpecStruct {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.println("Please enter base value: ");
- int base = sc.nextInt();
- for(int i = 1; i <= base; i++) {
- for(int j = 1; j <= i; j++) { // Loop for printing left triangle
- System.out.print("*");
- }
- for(int k = 0; k < (base-i)*2; k++) { // Loop for printing spaces
- System.out.print(" ");
- }
- for(int j = 1; j <= i; j++) { // Loop for printing right triangle
- System.out.print("*");
- }
- System.out.println(""); // moving to next line
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement