Area OR Perimeter: AREAPERI

CU Submission link: Click here

Public Submission link: Click here

Write a program to obtain length (L)(L) and breadth (B)(B) of a rectangle and check whether its area is greater or perimeter is greater or both are equal.

Input:

  • First line will contain the length (L)(L) of the rectangle.
  • Second line will contain the breadth (B)(B) of the rectangle.

Output:

Output 2 lines.

In the first line print “Area” if area is greater otherwise print “Peri” and if they are equal print “Eq”.(Without quotes).

In the second line print the calculated area or perimeter (whichever is greater or anyone if it is equal).

Constraints

  • 1≤L≤10001≤L≤1000
  • 1≤B≤10001≤B≤1000

Sample Input:

1
2

Sample Output:

Peri
6

EXPLANATION:

Area = 1 * 2 = 2

Peri = 2(1 + 2) = 6

Since Perimeter is greater than Area, hence the output is

Peri

6


Area OR Perimeter codechef solution in C++


int main() {
    int l,b,area,peri;
    cin>>l>>b;
    area = l*b;
    peri = 2*(l+b);
    if(area>peri)
    {
        cout<< "Area"<< endl<< area;
    }
    else
    if(area==peri)
    {
        cout<< "Eq"<< endl<< area;
    }
    else
    {
        cout<< "Peri"<< endl<< peri;
    }

	// your code goes here
	return 0;
}

Area OR Perimeter codechef solution in Python

# cook your dish here
l=int(input())
b=int(input())
area= l*b
peri= 2*(l+b)
if area>peri:
    print("Area")
    print(area)
elif area==peri:
    print("Eq")
    print(peri)
else:
    print("Peri")
    print(peri)

Area OR Perimeter codechef solution in Java

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		try{
            Scanner sc=new Scanner(System.in);
            int l=sc.nextInt();
            int b=sc.nextInt();
            int a=(l*b);
            int p=2*(l+b);
            if(a>p){
                System.out.println("Area");
                System.out.println(a);
            }
            else if(a< p){
                System.out.println("Peri");
                System.out.println(p);
            }
            else{
                System.out.println("Eq");
                System.out.println(p);
            }
        }
        catch(Exception e){
            System.out.println(e);
        }
	}
}


Area OR Perimeter codechef solution by

Area OR Perimeter codechef solution
Area OR Perimeter codechef solution
See also  First and Last Digit: FLOW004