Question
You need to read two side values S1 and S2
from the user and calculate the area & perimeter of the rectangle using
their side values and print the same.
Program
package area;
import java.util.Scanner;
public class Area
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
long s1 = in.nextLong();
long s2 = in.nextLong();
//long area = s1 * s2;
//long perimeter = 2 * (s1 + s2);
System.out.println("Area " + (s1 * s2));
System.out.println("Perimeter " + (2*(s1 + s2)));
}
}
import java.util.Scanner;
public class Area
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
long s1 = in.nextLong();
long s2 = in.nextLong();
//long area = s1 * s2;
//long perimeter = 2 * (s1 + s2);
System.out.println("Area " + (s1 * s2));
System.out.println("Perimeter " + (2*(s1 + s2)));
}
}
Very good
ReplyDelete