Java
Java
if (radius <= 0) {
System.out.println("Please enter a
non-zero positive number."); } else
{ // Calculate perimeter and area
double perimeter = 2 * Math.PI*
radius; double area = Math.PI*
radius * radius;
scanner.close(); } }
Explanation :
1. Input Handling: The radius is read from the user.
Solution :
Output:
Area of the rectangle: 15.0
Solution :
Output:
Run
Copy code
Welcome to the Simple Calculator!
Please enter the first number: 10
Please enter the second number: 5 Choose
an operation:
5. Addition (+)
6. Subtraction (-)
7. Multiplication ()
8. Division (/)
1
Result:10.0 + 5.0 = 15.0 Do you want to perform
another calculation?
(yes/No):