Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: someone help

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy someone help

    Hey everybody im really bad at programming can someone proofread this code and make the necessary corrections? i tried to do it myself and it never compiled. the code is for a dialog box that calculates the volume of a cylinder, and i know there are simpler codes to do it, but this is the format my teacher wants
    Heres the code:

        import javax.swing.*;
        public class classTwo
        {
            public static void main(String[] args)
            {
                String rad, hei, vol;
                Scanner joe = new Scanner(System.in);
                System.out.println ("Hi, please enter a radius.");
                double rad = joe.nextLine();
                System.out.println ("Enter a height.");
                double hei = joe.nextLine();
                vol = 3.14 * rad * rad * hei;
                System.out.println ("The volume of your cylinder is" + vol + ".");
            } 
        }

    P.S. im using BlueJ, if that is relevant
    Last edited by doodlydoo; August 31st, 2014 at 02:13 PM.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,382
    Thanks
    53
    Thanked 2,398 Times in 2,351 Posts

    Default Re: someone help

    Sorry, we don't do students work for them. We will help you get the code to work.

    If there are errors, copy the full text of the error messages and paste it here.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Aug 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: someone help

    on line 10, im getting a message that says "variable rad is already defined in method main(java.lang.String[])

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,382
    Thanks
    53
    Thanked 2,398 Times in 2,351 Posts

    Default Re: someone help

    variable rad is already defined
    You can only define a variable one time in the existing scope.
    You can reuse an existing variable as often as you want
    or you can change the name of the variable so it's different from the name of an existing variable.
    If you don't understand my answer, don't ignore it, ask a question.

Tags for this Thread