-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsquare.java
More file actions
33 lines (22 loc) · 773 Bytes
/
square.java
File metadata and controls
33 lines (22 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.util.Scanner;
public class square
{
/* Program that prompts for and reads an integer representing the length of a square's side,
then prints the square's perimeter and area
perimeter = 4 * side
area = side * side
*/
public static void main(String[] args)
{
int side;
int perimeter;
int area;
Scanner mySquare = new Scanner(System.in);
System.out.println("Enter the length");
side = mySquare.nextInt();
perimeter = 4 * side;
area = side * side;
System.out.println("Perimeter of Square is" + " " + perimeter);
System.out.println("Area of Square is" + " " + area);
}
}