Requirement
- Read one side of a rectangle from console
- Then read another side of rectangle
- Calculate the area of the rectangle
- Assign the area to a value
- Output the value of the area
Demo
import java.util.Scanner;
/**/*from ww w .jav a 2 s . co m*/
* Write a program that enters the sides of a rectangle (two integers a and b)
* and calculates and prints the rectangle's area
*/
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int aSide = input.nextInt();
int bSide = input.nextInt();
int rectangleArea = aSide * bSide;
System.out.println(rectangleArea);
}
}
Related Exercise