Computer Science, asked by dhruvkumar5095, 1 year ago

give a program of java (blue.j) to assign sides and find area​

Answers

Answered by arnav5chandorkar
1

Answer:

import java.util.Scanner;

class AreaTriangle {

  public static void main(String args[]) {    

     Scanner scanner = new Scanner(System.in);

     System.out.println("Enter the width of the Triangle:");

     double base = scanner.nextDouble();

     System.out.println("Enter the height of the Triangle:");

     double height = scanner.nextDouble();

     //Area = (width*height)/2

     double area = (base* height)/2;

     System.out.println("Area of Triangle is: " + area);      

  }

}

import java.util.Scanner;

class SquareArea {

  public static void main (String[] args)

  {

      System.out.println("Enter Side of Square:");

      //Capture the user's input

      Scanner scanner = new Scanner(System.in);

      //Storing the captured value in a variable

      double side = scanner.nextDouble();

      //Area of Square = side*side

      double area = side*side;  

      System.out.println("Area of Square is: "+area);

  }

}

import java.util.Scanner;

class AreaOfRectangle {

  public static void main (String[] args)

  {

   Scanner scanner = new Scanner(System.in);

   System.out.println("Enter the length of Rectangle:");

   double length = scanner.nextDouble();

   System.out.println("Enter the width of Rectangle:");

   double width = scanner.nextDouble();

   //Area = length*width;

   double area = length*width;

   System.out.println("Area of Rectangle is:"+area);

  }

}

import java.util.Scanner;

public class Area

{

   public static void main(String[] args)  

   {

       int r;

       double pi = 3.14, area;

       Scanner s = new Scanner(System.in);

       System.out.print("Enter radius of circle:");

       r = s.nextInt();

       area = pi * r * r;

       System.out.println("Area of circle:"+area);

   }            

}

Similar questions