Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 896401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:43:28+00:00 2026-05-15T14:43:28+00:00

Simple program to just find the circumference, diameter, and area of a circle. Whenever

  • 0

Simple program to just find the circumference, diameter, and area of a circle. Whenever I run the program it’s fine, just at the end there’s always a 1 or -1 after the value for Area. For example, when using a radius of 10 I get:

Results
The circumference of the circle is: 62.832 Centimeters
The diameter of the circle is: 20.0 Centimeters
The area of the circle is: 314.159 Centimeters1

Code is as follows below:

import javax.swing.JOptionPane;
import java.text.DecimalFormat;

public class Circle {

    public static void main(String[] args)
    {
    //Declarations
    double radius;
    String getRadius;

    //Formatting
    DecimalFormat formatter = new
    DecimalFormat(".000");

    //Calculations
    getRadius = JOptionPane.showInputDialog("Enter Circle Radius In Centimeters:");
    radius = Double.parseDouble(getRadius);

    //Output
    JOptionPane.showMessageDialog(null, "Results" + 
            "\n The circumference of the circle is: " + formatter.format(2*Math.PI*radius) + " Centimeters" +
            "\n The diameter of the circle is: " + 2*radius + " Centimeters" +
            "\n The area of the circle is: " + formatter.format(Math.PI*Math.pow(radius,2)) + " Centimeters" +
            JOptionPane.INFORMATION_MESSAGE);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T14:43:28+00:00Added an answer on May 15, 2026 at 2:43 pm

    You’re appending JOptionPane.INFORMATION_MESSAGE (which happens to equal 1) to your string. It should be something like:

    JOptionPane.showMessageDialog(null, 
            "Results" + 
            "\n The circumference of the circle is: " + formatter.format(2*Math.PI*radius) + " Centimeters" +
            "\n The diameter of the circle is: " + 2*radius + " Centimeters" +
            "\n The area of the circle is: " + formatter.format(Math.PI*Math.pow(radius,2)) + " Centimeters", 
            "Results", 
            JOptionPane.INFORMATION_MESSAGE);
    

    The four parameters are parent, message, title, messageType. Before, you were accidentally using the two-parameter version (parent, message) and appending the messageType to your message.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just starting out writing trying to write a simple program in C and
I want to develop simple Serverless LAN Chat program just for fun. How can
I'm trying to write a simple program in VC++ which will just initialize the
Is there a simple database program to let me collect, sort, tag, and reguritate
I'm writing a simple program to browse the local network and pass on filenames
I'm writing a simple program to help generate orders for a game I'm a
I'm planning to make a very simple program using php and mySQL. The main
I'm trying to compile a simple program, with #include <gtkmm.h> The path to gtkmm.h
In my simple OpenGL program I get the following error about exit redefinition: 1>c:\program
Consider the following simple C program that read a file into a buffer and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.