Java 1.3: area of rectangle II

areaOfRect2

import java.util.Scanner;

public class Main {

    static int [] side = {0, 0};

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        // scan is the variable name
        int area;

        System.out.print("Enter length: ");
        side[0] = scan.nextInt();

        System.out.print("Enter height: ");
        side[1] = scan.nextInt();

        area = side[0] * side[1];

        System.out.println("The area of your rectangle is: " + area);
    }
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s