Avatar of jerry-2112
jerry-2112
Flag for Afghanistan asked on

New to Java Using Eclipse for a class with only C# programming in the past

I'm in a Java programming class.  Pretty basic for most of you guys.  I've only done C# programming in the past.  Pretty new to programming to start with anyway.  Already getting errors on the following program.  Trying to us the \n to start the next line.  Something I never did in C#.  Here is a look at my code and the errors I get.  Does anybody know a good began-er book with sample codes ? I work better by seeing examples.  Thanks please tell me what I'm missing here.

 String radius; //radius entered by user
        double radius1; // converted user input
             
        //get radius from user
        radius = JOptionPane.showInputDialog("Enter the Radius");
        //convert numbers from string to type Double
        radius1 = Double.parseDouble(radius);
     
        JOptionPane.showMessageDialog(null,  "The Diameter Is " +      (2*radius1)"\nThe Circumference Is "
       + (2 * Math.PI * radius1) " \nThe Area Is " + (Math.PI * radius1 * radius1));



When I separate I get it to work, but my lab is to have all in one display box.
This works but .....
 String radius; //radius entered by user
        double radius1; // converted user input
       
        //get radius from user
        radius = JOptionPane.showInputDialog("Enter the Radius");
        //convert numbers from string to type Double
        radius1 = Double.parseDouble(radius);
     
        JOptionPane.showMessageDialog(null,"The Diameter Is " + (2*radius1));
        JOptionPane.showMessageDialog(null,"\nThe Circumference Is "+ (2 * Math.PI * radius1));
        JOptionPane.showMessageDialog(null, " \nThe Area Is " + (Math.PI * radius1 * radius1));
JavaJava EEC#

Avatar of undefined
Last Comment
CEHJ

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
kaufmed

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
jerry-2112

ASKER
Thanks you are right about the (+) .  It did work.  1st I had to String result = .  Then in my display I had to display the result.
CEHJ

I would strongly recommend String.format for this case. Check the api docs
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy