Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Triangle1 {
- public static void main(String[] args) throws Exception {
- Scanner input = new Scanner(System.in);
- double base = 0;
- double height = 0;
- double area = 0;
- System.out.print("Enter the length of base of triangle in cm : ");
- base = input.nextDouble();
- System.out.print("Enter the length of height of triangle in cm : ");
- height = input.nextDouble();
- area = (base * height) / 2;
- System.out.println("");
- System.out.println("The Area of Triangle is : "
- + area );
- System.out.println();
- System.out.println("Visual");
- for (int i=1; i<=area;i++)
- {
- for (int j=1;j<=area;j++)
- {
- if (j<=i)
- System.out.print("*");
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement