Advertisement
Guest User

Untitled

a guest
Dec 17th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Triangle1 {
  4.  
  5.  
  6. public static void main(String[] args) throws Exception {
  7. Scanner input = new Scanner(System.in);
  8.  
  9. double base = 0;
  10. double height = 0;
  11. double area = 0;
  12.  
  13. System.out.print("Enter the length of base of triangle in cm : ");
  14. base = input.nextDouble();
  15.  
  16. System.out.print("Enter the length of height of triangle in cm : ");
  17. height = input.nextDouble();
  18.  
  19. area = (base * height) / 2;
  20.  
  21. System.out.println("");
  22. System.out.println("The Area of Triangle is : "
  23. + area );
  24. System.out.println();
  25.  
  26. System.out.println("Visual");
  27.  
  28. for (int i=1; i<=area;i++)
  29. {
  30. for (int j=1;j<=area;j++)
  31. {
  32. if (j<=i)
  33. System.out.print("*");
  34. }
  35. System.out.println();
  36. }
  37.  
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement