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: Conditions?

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Location
    England
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Conditions?

    Hi guys just started out, this is my code so far:

    Scanner scan = new Scanner(System.in);
    System.out.println("This is a program used to find the circumference "
    + "and diameter of a circle.");
    System.out.println("Enter the radius of your circle:");
    double r =scan.nextDouble();
    double d = r*2;
    double c = d*3.1415;
    double f = r*r;
    double a = 3.1415*f;
    System.out.println("The Circumference of your circle is: "+c+" and the "
    + "diamterer of your circle is: "+d+".");
    System.out.println("Would you like to know the area of your circle?");

    What i plan to add to my code is to give the user the choice of wether they want to know the area of the circle or wether they dont (by making them answer either yes or no) any ideas on how to do this? and feedback would really help, Thanks.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Conditions?

    Please post your code in code tags. How to do that and other useful info is contained in the Announcements at the top of the "What's Wrong With My Code?" forum.

    Accept the user's answer and use an if statement to determine which action to take. You can learn more about controlling program flow here.

  3. #3
    Junior Member
    Join Date
    Sep 2013
    Location
    England
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Conditions?

    I will do and thanks allot was really helpful i've managed it now, Thanks again!

  4. #4
    Junior Member
    Join Date
    Sep 2013
    Location
    England
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Conditions?

    I will do and thanks allot was really helpful i've managed it now, Thanks again!

Similar Threads

  1. JComboBox conditions?
    By maronski in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 9th, 2013, 07:28 PM
  2. Can you help me decipher what these two conditions mean in pseudocode?
    By divebomb33 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: November 2nd, 2012, 07:49 PM
  3. Conditions and 'might not have been initialized' error.
    By mwebb in forum What's Wrong With My Code?
    Replies: 8
    Last Post: October 2nd, 2011, 11:22 AM
  4. Loop conditions not working
    By bmxershane in forum What's Wrong With My Code?
    Replies: 4
    Last Post: May 1st, 2011, 02:25 AM
  5. Hangman help. Comparing arrays and conditions.
    By javanewbie1 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 18th, 2011, 09:26 AM

Tags for this Thread