Problem

I am making a program that asks for a circles radius, then out puts the area, diameter, and circumference in a dialog box. I have everything working but I can not figure out how to make the results appear in one dialog box instead of three.

any help would be appreciated

Thanks

import javax.swing.JOptionPane;

publicclass radius{

publicstaticvoid main ( String args [] ){

String radius;

double radiusfloat;

double area;

double circ;

double diameter;

double pi = 3.14159;

radius = JOptionPane.showInputDialog("Enter the radius of a circle" );

radiusfloat = Double.parseDouble (radius);

diameter = 2 * radiusfloat;

area = (radiusfloat * radiusfloat) * pi;

circ = 2 * pi * radiusfloat;

JOptionPane.showMessageDialog (null,"The Diameter is " + diameter,"Results" , JOptionPane.PLAIN_MESSAGE );

JOptionPane.showMessageDialog (null,"The Area is " + area,".", JOptionPane.PLAIN_MESSAGE );

JOptionPane.showMessageDialog (null,"The Circumfrence is " + circ,".", JOptionPane.PLAIN_MESSAGE );

}//end of public static main

}// end of public class radius

[1938 byte] By [joshuapbella] at [2007-11-27 7:28:42]
# 1
How about you put all the info you want displayed in a single String.
floundera at 2007-7-12 19:08:50 > top of Java-index,Java Essentials,Java Programming...
# 2

Okay here is my new code with everything as one string, but how do I format it so each one is on a new line?

import javax.swing.JOptionPane;

public class radius {

public static void main ( String args [] ) {

String radius;

double radiusfloat;

double area;

double circ;

double diameter;

double pi = 3.14159;

radius = JOptionPane.showInputDialog( "Enter the radius of a circle" );

radiusfloat = Double.parseDouble (radius);

diameter = 2 * radiusfloat;

area = (radiusfloat * radiusfloat) * pi;

circ = 2 * pi * radiusfloat;

JOptionPane.showMessageDialog (null, "The Diameter is " + diameter +

" The area is " + area +

" The Circumference is " + circ,

"Results" , JOptionPane.PLAIN_MESSAGE );

}//end of public static main

}// end of public class radius

joshuapbella at 2007-7-12 19:08:50 > top of Java-index,Java Essentials,Java Programming...
# 3
You could try the newline char '\n'
floundera at 2007-7-12 19:08:50 > top of Java-index,Java Essentials,Java Programming...
# 4
Duh, always something obvious!
joshuapbella at 2007-7-12 19:08:50 > top of Java-index,Java Essentials,Java Programming...