Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Integer Arrays, Random Numbers, Try-Catch Validation

    I have no idea what I am doing for this program. Can someone help me?



    You are to write a program that will simulate rolling a set of 2 or more dice with 3 or more sides, track how many times each total is thrown, then print a bar graph that shows how many times each total was thrown.

    This will be coded in a single application class that is well decomposed. Well decomposed means you avoid writing duplicate code, you write several small helper methods and a single public main method. Absolutely no method can be over 20 lines long – including the header, all curly braces on individual lines, and use of white space for easily readable code.

    Your program must be 100% validated – meaning if the user enters string data for integer values they get a proper error message and are required to re-enter rather than having the program blow up. Other values must also be validated (as described later). You must use at least 2 try-catch blocks for validation.

    In addition you must have at least one method that has an array as a parameter variable and you must have at least one method that has an array as a return value.

    You are to ask the user for the number of dice to throw – this must be at least 2.

    You are to ask the user for the number of sides on each dice – this must be at least 3. All dice thrown will have the same number of sides.

    You should roll the dice at least 100 times the number of dice thrown.

    You should allow your user to run the application as many times as they want, changing both the number of dice and the number of sides with each round.

    You must start with an explanation of the application’s function and end with an exit message thanking the user for playing.

    For example if the user asks to throw 2 dice with 3 sides each the bar graph might look like this
    2: ************************
    3: **********************************************
    4: *******************************************************************
    5: ****************************************
    6: ***********************

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Quote Originally Posted by kp2630 View Post
    I have no idea what I am doing for this program. Can someone help me?
    Not if your intention is to plagiarize the code as your own. You need to post very specific questions as to the problem you are having, along with your current supporting code.
    If you are at a complete loss, you must contact your instructor for clarification to the assignment.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •