Computer Science, asked by sanskaargupta2708, 16 days ago

Take 2 sides of a quadrilateral from the user, check if it is a square or
rectangle. Print its area and perimeter accordingly.
a. Write an algorithm for the above situation.
b. Draw a flowchart for the above situation.

Answers

Answered by samarthkrv
0

Answer:

import java.util.*;

public class Main

{

public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

 System.out.print("Enter the length of side a:");

 int a = sc.nextInt();

 System.out.print("Enter the length of side b:");

 int b = sc.nextInt();

     if(a==b){

         System.out.println("The quadrilateral is a square and area is " + (a*a) + " and perimeter is " + (a*4));

     }

     else{

         System.out.println("The quadrilateral is a rectangle and the area is " + (a*b) + " and the perimeter is " + 2*(a+b));

     }

}

}

Explanation:

Similar questions