Question

Please write in JAVA ONLY Please use a dialog box to prompt the user to enter...

Please write in JAVA ONLY

Please use a dialog box to prompt the user to enter the radius for a circle (radius should be a double).

Then, use a Message Box to display the Radius, Area and Circumference of the circle with that Radius.

You will use the Math class constant Math.PI to calculate the Area and Circumference.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CircleArea.java

import javax.swing.JOptionPane;


public class CircleArea {

  
   public static void main(String[] args) {
       double radius = Double.parseDouble(JOptionPane.showInputDialog("Enter circle radius: "));
       double area = Math.PI * radius * radius;
       double circumference = 2 * Math.PI * radius;
       JOptionPane.showMessageDialog(null, "Circle Radius is "+radius+" Area is "+area+" Circumference is "+circumference);
   }

}

Output:

Input Enter circle radius: 8.5 OK CancelMessage Circle Radius is 8.5 Area is 226.98006922186258 Circumference is 53.40707511102649 OK

Add a comment
Know the answer?
Add Answer to:
Please write in JAVA ONLY Please use a dialog box to prompt the user to enter...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a Java console application that prompts the user to enter the radius of a circle,...

    Write a Java console application that prompts the user to enter the radius of a circle, then prints its radius, diameter, circumference, and area. Write a JavaFX GUI application to do the same calculation, and draw the circle. The Console Output Enter the radius of the circle: 1.2 The radius is 1.2 The diameter is 2.4 The circumference is 7.5398223686155035 The area is 4.523893421169302 Write and document your program per class coding conventions. Add an instance variable double radius. Generate...

  • Java only please Write a program that displays the following menu: Geometry Calculator 1.       Calculate the...

    Java only please Write a program that displays the following menu: Geometry Calculator 1.       Calculate the Area of a Circle 2.       Calculate the Area of a Triangle 3.     Calculate the Area of a Rectangle 4.       Quit Enter your choice (1-4): If the user enters 1, the program should ask for the radius of the circle and then display its area. Use the formula:      area = ∏r2    Use 3.14159 for ∏. If the user enters 2 the program should ask for...

  • Java Write a program that prompt the user to enter a decimal number representing the radius...

    Java Write a program that prompt the user to enter a decimal number representing the radius of a circle. If the number is greater or equal to zero, the program displays the area of the circle. Otherwise, the program displays “negative input”

  • Menu-driven programs will display the menu options to the user and then prompt them for a...

    Menu-driven programs will display the menu options to the user and then prompt them for a menu choice. This program will display the following menu in the following format: Calculator Options: Calculate the area of a circle Calculate the area of a rectangle Calculate the area of a triangle Calculate the area of a trapezoid Calculate the area of a sphere Exit Enter your choice (1-6) Once the user enters a choice for the menu, the program should use a...

  • 2. Write a JavaScript to create a. Alert Dialog Box b. Confirmation Dialog Box c. Prompt...

    2. Write a JavaScript to create a. Alert Dialog Box b. Confirmation Dialog Box c. Prompt Dialog box 3. Write a JavaScript to Change an image when a user holds down the mouse button. 4. Write a JavaScript to display all the cookies set on your machine. 5. Write a JavaScript to disable right click on the page

  • Write a java class definition for a circle object. The object should be capable of setting...

    Write a java class definition for a circle object. The object should be capable of setting radius, and computing its area and circumference. Use this to create two Circle objects with radius 10 and 40.5, respectively. Print their areas and circumference. Here is the Java class file (Circle.java). Compile it. public class Circle{ //Instance Variables private double PI = 3.1459; private double radius; //Methods public Circle ( ) { }    //get method (Accessor Methods ) public double getRadius (...

  • Write an ADT named circle in java containing the following. Include data: radius (double) Include methods:...

    Write an ADT named circle in java containing the following. Include data: radius (double) Include methods: A no-argument constructor A constructor that sets the data to passed values Getters and setters for each piece of data getArea (Math.PI * radius * radius … try using a Math method here) getDiameter (radius * 2) getCircumference (2 * Math.PI * radius) A toString( ) method to display the object data Include Javadoc comments for the class and every method, and generate the...

  • Project 4: Month-end Sales Report with array and validation Input dialog box for initial user prompt...

    Project 4: Month-end Sales Report with array and validation Input dialog box for initial user prompt with good data and after invalid data Input OK Cancel Input dialog boxes with sample input for Property 1 Ingut X Input Enter the address for Property 1 Enter the value of Property 1: OK Cancel Input dialog boxes after invalid data entered for Property 1 Error Please enter anmumber greater than D Ester the walue of Peoperty t Console output END SALES REPORT...

  • Write a main method that will request the user to enter Strings using a JOptionPane input...

    Write a main method that will request the user to enter Strings using a JOptionPane input dialog. The method should continue accepting strings until the user types “STOP”. Then, using a JOptionPane message dialog, tell the user how many of the strings contained only letters. Hint: there is a method isLetter in the wrapper class Character. in JAVA

  • ***** JAVA ONLY ***** Write a program that asks the user to enter the name of...

    ***** JAVA ONLY ***** Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the file. Use Notepad to create a simple file that can be used to test the program. ***** JAVA ONLY *****

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT