e) Write a java program to accept length and breadth of a rectangle.Calculate and print area of rectangle
Answers
Answer:
public class rectangle{
public static void main(String args[])
{
int width=5;
int height=10;
int area=width*height;
System.out.println("Area of rectangle="+area);
import java.util.Scanner; //importing Java.util package
public class rectangle //class declared
{ //class block starts
public static void main(String [] args) //function declared
{ //function block starts
Scanner in = new Scanner(System.in); //creating object of scanner class
int area, l, b; //variable declared of int data type
System.out.println("Enter length of the rectangle"); //printing message
int l = in.nextInt( ); //function to enter int data
System.out.println("Enter the breadth of the rectangle"); //printing message
int b = in.nextInt( ); //function to enter int data
System.out.println("Area of rectangle =" + (l*b)); //calculating and printing area of rectangle
} //function block ends
} //class block ends