Question: Consider the following Java program in which the statements are in the incorrect order. Rearrange the statements so that it prompts the user to input
Consider the following Java program in which the statements are in the incorrect order. Rearrange the statements so that it prompts the user to input the length and width of a rectangle and output the area and perimeter of the rectangle.
public class Ch2_PrExercise5 { static Scanner console = new Scanner(System.in); import java.util.*; { public static void main(String[] args) int width; System.out.print("Enter the length: "); width = console.nextInt(); System.out.println(); int length; System.out.print("Enter the width: "); length = console.nextInt(); System.out.println(); area = length * width; System.out.println("Area = " + area); System.out.println("Perimeter = " + perimeter); perimeter = 2 * (length + width); int area; int perimeter; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
