Question

# (Use Java ) please write comment on every line I need to understand the code Problem...

(Use Java )

please write comment on every line I need to understand the code

Problem Description:

Write a program that prompts the user to enter a point (x, y) and checks whether the point is within the rectangle centered at (0, 0) with width 10 and height 5. For example, (2, 2) is inside the rectangle and (6, 4) is outside the rectangle, as shown in the Figure.

(Hint: A point is in the rectangle if its horizontal distance to (0, 0) is less than or equal to 10 / 2 and its vertical distance to (0, 0) is less than or equal to 5 / 2.)

Here are sample runs of the program:

Sample 1:

Enter a point with two coordinates: 2 2

Point (2.0, 2.0) is in the rectangle

Sample 2:

Enter a point with two coordinates: 6 4

Point (6.0, 4.0) is not in the rectangle

Submit your group video presentation using Zoom. In your video cover the following:

Analysis:

(Describe the problem including input and output in your own words.)

Design:

(Describe the major steps for solving the problem.)

Coding: (Go over your code step by step)

Testing: (Describe how you test this program). In other words run your code with sample outputs.

Hope you like the answer I explain the question in a program through comment section and please upvote me for the efforts

import java.util.Scanner;

public class Solver {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

// Prompt the user to enter a point (x, y)

System.out.print("Enter a point with two coordinates: ");

double x = input.nextDouble();

double y = input.nextDouble();

// Check whether the point is within the rectangle

// centered at (0, 0) with width 10 and height 5

boolean withinRectangle = (Math.pow(Math.pow(x, 2), 0.5) <= 10 / 2 ) ||

(Math.pow(Math.pow(y, 2), 0.5) <= 5.0 / 2);

// Display results

System.out.println("Point (" + x + ", " + y + ") is " +

((withinRectangle) ? "in " : "not in ") + "the rectangle");

}

}

Output :

Enter a point with two coordinates: 2 2

Point (2.0, 2.0) is in the rectangle

#### Earn Coins

Coins can be redeemed for fabulous gifts.