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 6 of 6

Thread: Trying to clean this part of my progam up, but cant seem to get it.

  1. #1
    Junior Member
    Join Date
    Feb 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Trying to clean this part of my progam up, but cant seem to get it.

    Im trying to get the area of a square, rectangle, and a circle.

    i have to include all this and I'm just stuck!

    Use System.out.println to display the calculated values to the computer screen. Make sure the output includes words as well as numbers so the user will know what the values pertain to. Include appropriate units with the displayed calculated values.

    Use the Java Scanner feature. Prompt the user to make a decision on whether s/he wants to determine the area of 1. a square, 2. a rectangle, or 3 a circle. Do not allow the user to determine the areas of all three shapes without rerunning the program.

    Ask the user for the dimension units (feet, inches, meters, centimeters, millimeters) that would be associated with the values entered for the length of the side of a square, the length/width of a rectangle and the diameter/radius of the circle.
    Make use of the Math.PI and Math.pow features of Java.
    Attached Files Attached Files


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: Trying to clean this part of my progam up, but cant seem to get it.

    Welcome to the forums Mod31.

    I'm afraid no one here is going to do your assignment for you.

    Is the attached code the work you have done on this already? If so, please post this code within the highlight tags. See my signature.
    Show us where you are stuck. Show us you have made an effort and we will take it from there..
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  3. #3
    Junior Member
    Join Date
    Feb 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Trying to clean this part of my progam up, but cant seem to get it.

    Yes the attachment is my code i've been working on, and im sorry i didnt mean to make it seem that I wanted someone to do it for me.

  4. #4
    Junior Member
    Join Date
    Feb 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Trying to clean this part of my progam up, but cant seem to get it.

     import java.util. Scanner;
     
    public class Assignment7
     
     
    {       // Open assignment7
     
            public static void main(String[] args)
     
            {       // Open Main
     
                    /***** Declare Variables *****/
     
                    int     squareSide,       
                            rectangleSide, rectangleWidth,
                            radCircle;
     
                    double  areaSquare,
                            areaRectangle,
                            areaCircle;
     
                        System.out.print("\n\n\n\n what units would you like to use?");
     
     
                    ///////// Prompt User for Values //////////
     
                    System.out.print( "|n\n\n\n Which would you like to find the area for \n a square (A) , \n ") ;
                    System.out.print(" for a rectangle (B) , \n");
                    System.out.print( " for a circle (C)? , \n\n");
     
                    System.out.println( "\n");              
                    System.out.println("\n\n Choice = " + Choice);
     
     
                    ///////// Create Simple Nested If Else Statement/////////
                    if ( Choice == A)
     
                       {
     
                       System.out.println("\n\n\n Enter the length of a square \n\n\n"); 
     
                       areaSquare =  squareSide * squareSide;
     
                       System.out.println("\n\n\n the area for a square = " + areaSquare + " square " + units  +".");
                       }
     
     
                    }   // end main
     
    }     // end assignment7

  5. #5
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: Trying to clean this part of my progam up, but cant seem to get it.

    No problem. I am glad you have started this.

    Lots of users post assignments and expect people to complete it without showing an effort on their part.

    So lets take this one step at a time. What part are you stuck on?
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  6. #6
    Junior Member
    Join Date
    Feb 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Trying to clean this part of my progam up, but cant seem to get it.

    when i enter into my command prompt i get a lot of errors but cant seem to even fix them, and when i fix the problem it ask for what i deleted prior to that. I'm also having trouble getting started with the (Choice ==A) idk what im doing wrong do I have to initialize A,B,C somewhere?

Similar Threads

  1. Please help me clean up my code!
    By Java Neil in forum What's Wrong With My Code?
    Replies: 8
    Last Post: February 25th, 2011, 02:48 PM
  2. can' stop working a part of code.plzz help
    By kyros in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 30th, 2010, 04:10 PM
  3. Paint only part of screen
    By bonus_clip in forum AWT / Java Swing
    Replies: 7
    Last Post: October 16th, 2010, 08:21 PM
  4. How to write to specific part of an html file using java
    By nasi in forum File I/O & Other I/O Streams
    Replies: 12
    Last Post: May 28th, 2010, 12:22 AM
  5. [SOLVED] "GridLayout" problem in Java program
    By antitru5t in forum AWT / Java Swing
    Replies: 3
    Last Post: April 16th, 2009, 11:26 AM