by Dinesh Thakur Category: Control Structures

 

 

import java.util.Scanner; 

     
    public class ScanTri

        public static void main (String[] args) 
    { 
            System.out.println("Enter the Size of a triangle, an integer from 1 to 50 please."); 
     
            Scanner scan = new Scanner(System.in); 
            int min, max; 
            int tot = scan.nextInt(); 
             
            for(min = 0; min <= tot; min++)
          { 
                for(max = 0; max < min; max++)
               { 
                    System.out.print("*"); 
                } 
                System.out.println(); 
            } 
            for(min = tot-1; min >= 0; min--)
           { 
                for(max = min-1; max >= 0; max--)
               { 
                    System.out.print("*"); 
                } 
                System.out.println(); 
            } 
     
        } 
     
    }




About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles