0% found this document useful (0 votes)
69 views1 page

Class Public Static Void: "Hello World!"

This Java program prompts the user to input the length and width of a rectangle using a Scanner object. It then calculates the area by multiplying the length and width, and prints the result.

Uploaded by

Damir K
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views1 page

Class Public Static Void: "Hello World!"

This Java program prompts the user to input the length and width of a rectangle using a Scanner object. It then calculates the area by multiplying the length and width, and prints the result.

Uploaded by

Damir K
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

class Main {

public static void main(String[] args) {


System.out.println("Hello world!");
}
}

import java.util.Scanner; // Needed for Scanner class


class Main {
public static void main(String[] args) {
int length;
int width;
int area;
Scanner console = new Scanner(System.in);
System.out.print("Enter length");
length = console.nextInt();
System.out.print("Enter width");
width = console.nextInt();
area=length*width;
System.out.println("Area of rectangle is" + area);

}
}

You might also like