Question: Learning objective: Calculate a simple result. Class to edit: Exercise 7 Write a program that calculates and prints the area of a square according to

 Learning objective: Calculate a simple result. Class to edit: Exercise 7

Learning objective: Calculate a simple result. Class to edit: Exercise 7 Write a program that calculates and prints the area of a square according to the following sample I/O : Enter square side length: "user inputs 2.5 " The area of the square is 6.25 Notice that all numbers and calculations are performed using the double data type. When calculating something, it is usually convenient to temporarily store the result into a local variable such as: double area = "formula for the area of a square "; Your solution should be 3 lines of code: 1. Ask for the square side length and store it into a variable. 2. Calculate the area and store it in another variable. 3. Print the area. Hint: The formula for the area of a square is length 2. There are two ways to calculate the square of a number. You could multiply length * length or you could use the Math.pow () method to calculate length to the power of 2

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!