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

Thread: Question about assingment.

  1. #1
    Member
    Join Date
    Dec 2012
    Location
    Detroit Mi
    Posts
    122
    My Mood
    Amazed
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Default Question about assingment.

    Here is my assignment.

    Write a Java program that prompts the user to enter five values of type double and displays their average as an integer. Use CASTING and NO points for this if you use five different variables.

    I really don't know how she wants me to use one variable. Could some one better explain this problem.

    Thanks Again!


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Question about assingment.

    spoon-feeding answer deleted. Let's help folks learn Java, but let's not simply do their work for them.

    --- Update ---


    To Rain_Maker: Declare a double variable, sum, before your for loop, and inside the loop, use a Scanner to get a value that is immediately added to sum.

  3. The Following User Says Thank You to curmudgeon For This Useful Post:

    Rain_Maker (February 7th, 2013)

  4. #3
    Member
    Join Date
    Dec 2012
    Location
    Detroit Mi
    Posts
    122
    My Mood
    Amazed
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Default Re: Question about assingment.

    Ohhhhh I see what you mean!!! I figured I was going to use some type of loop but I didn't know how I was going to use it. So basically I'm going to ask the user 5 times for a value of double. Each time the loop is asked the value will be added. From there I will have my final value. If I'm understanding this right.

  5. #4
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Question about assingment.

    Quote Originally Posted by Rain_Maker View Post
    Ohhhhh I see what you mean!!! I figured I was going to use some type of loop but I didn't know how I was going to use it. So basically I'm going to ask the user 5 times for a value of double. Each time the loop is asked the value will be added. From there I will have my final value. If I'm understanding this right.
    It sounds like you're on the right track, but to be sure, code it up and see what happens. To get the best experience from this class, I suggest that you code up any ideas you have, and that you play with and adjust your code frequently to see what happens. Think of the Java compiler as a grand science lab that you get to play in to your heart's content.

  6. #5
    Junior Member
    Join Date
    Dec 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Re: Question about assingment.

    Quote Originally Posted by curmudgeon View Post
    spoon-feeding answer deleted. Let's help folks learn Java, but let's not simply do their work for them.

    --- Update ---


    To Rain_Maker: Declare a double variable, sum, before your for loop, and inside the loop, use a Scanner to get a value that is immediately added to sum.


    Oops sorry, it's my first time here. :3

  7. #6
    Member
    Join Date
    Dec 2012
    Location
    Detroit Mi
    Posts
    122
    My Mood
    Amazed
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Default Re: Question about assingment.

    Hey curmudgeon never got to thank you. But I resolved the issue.

    Thanks Again!

  8. #7
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Question about assingment.

    Great -- glad it helped!

Similar Threads

  1. Pl help with my class assingment
    By ristory in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 5th, 2012, 03:35 AM
  2. Assingment help
    By bjcdude in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 8th, 2011, 06:09 PM