Question: DESCRIPTION: Write a program that uses the side length of a square to compute the perimeter and area of the square. Output the result in

DESCRIPTION: Write a program that uses the side length of a square to compute the perimeter and area of the square. Output the result in the exact format shown below.

Formulas for square calculations:

Perimeter: add all sides --> multiply the side length by 4

Area: side length squared --> multiply the side length by itself

SPECIFICATIONS:

Starter code has been provided for this lab. Look for it in the project folder in Mimir.

The starter code contains the code to get the number from the user. It will be stored as an integer with the name length. Don't worry about how this works yet - coming soon!

The filename for this program is Square.java

Complete the findSquareStuff() method to compute and output the perimeter and area as shown below.

Add a comment with your name, date, and program description at the top (update the comment that is already there) and answer the comment questions at the end.

SAMPLE OUTPUT (Example - if the side length is 10, the perimeter should be 40.0 and the area should be 100.0):

==================

Enter the length:

10

The perimeter of the square is 40.0

The area of the square is 100.0

==================

/*

Name

Date

Program Description (sentence)

/

import java.util.Scanner;

public class Square {

public static void main(String[] args) {

findSquareStuff(); // this method gets a number from the user

// and outputs the perimeter and area of the square

}

// this method gets a number from the user,

// calculates the perimeter and area of the square, and outputs them

public static void findSquareStuff() {

// Instantiate a Scanner to take input from the user

Scanner scanner = new Scanner(System.in);

// Prompt the user for side length and store the input in the variable length

System.out.println("Enter the length:");

int length = scanner.nextInt();

/////////////////////// INSERT YOUR CODE BELOW THIS LINE ///////////////////////

int length;

/////////////////////// INSERT YOUR CODE ABOVE THIS LINE ///////////////////////

scanner.close();

}

}

/

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!