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

Thread: Beginner Do-While Loop help please?

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

    Default Beginner Do-While Loop help please?

    Greetings, I am new to Java Programming

    I need to create a simply application that would display the results of two dice thrown five times and the total of those results. This is shown below in the attached file.

    The problem is, I have a do-while loop that loops 6 times. Inside the loop, I have 2 random.nextInt(5) that generate random numbers. But how can I output the total? How can I make a variable equal to the sum of the two random numbers if the two random numbers are located inside a do-while loop?

    Attached below is also the code I have thus far, please look at it and help me!

    Thanks in advance! and Sorry if I wrote it in a confusing fashion!

    (Attached below is both files: what it needs to look like, and what it currently looks like)
    Attached Images Attached Images


  2. #2
    Member
    Join Date
    May 2014
    Posts
    36
    Thanks
    6
    Thanked 3 Times in 3 Posts

    Default Re: Beginner Do-While Loop help please?

    If your loop needs to run a certain amount of times, you should look into for loops.
    And an array is a good place to store variables.
    English is not my native language (Typo alert).

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

    Default Re: Beginner Do-While Loop help please?

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Copy/paste your code directly into a post between code or highlight tags per the above link. The graphics are hard to read and can't be used as graphics.

Similar Threads

  1. Beginner help with a do loop
    By sorbazz in forum Loops & Control Statements
    Replies: 4
    Last Post: December 9th, 2012, 09:57 PM
  2. Beginner: For loop excercise (stuck)
    By ObedMarsh in forum Loops & Control Statements
    Replies: 4
    Last Post: September 8th, 2012, 07:37 PM
  3. Beginner for loop
    By gerre in forum Loops & Control Statements
    Replies: 11
    Last Post: August 2nd, 2012, 03:43 AM
  4. Loop Question - Very new beginner
    By Callcollect in forum Loops & Control Statements
    Replies: 12
    Last Post: January 18th, 2012, 04:01 AM
  5. [SOLVED] While Loop Help (beginner)
    By Perplexing in forum Loops & Control Statements
    Replies: 4
    Last Post: October 23rd, 2010, 02:00 PM