# can someone help me with a program?

• 02-08-2013, 05:35 PM
Aziombi
can someone help me with a program?
so i have a program i have to write because i broke my ankle and im going to be out of school for a few days.. heres the instructions i was given.
Create a DiceGame.java which does the following:

-
-
-
-

Allot the user \$10.00 of “pretend” money to play the game.
Let the user play the game until they enter the word “done”, or they run out of money.
The game rolls 2 dice each time. The values of each dice are added up to get the total value of the roll.
The user should always be presented the following choices:

Choice:
even
odd
fib
double
exact

done

Meaning:
The total roll is going to be even
The total roll is going to be odd
The total roll is a Fibonacci number
The two dice will have the same number
The user is able to specify the exact dice roll
(you will have the prompt the user for a roll amount)
quit program

Fixed bet amount:
\$0.50
\$0.50
\$1.00
\$2.00
Allow user to enter amount

-

If the user does not have enough money to choose “double” or “exact” then print out “not enough money for this
bet” and loop again.
Before each roll, the program should display the amount of money the user has and the above choice list.
After each roll, it should display the actual roll. If the user won or lost, randomly display a winning message (like
“Hooray – you in da money!”) or losing message (like “Better luck next time, pal!”.
o You must create two text files:
 winningmessages.txt – which contains 10 winning messages that you make up yourself
 losingmessages.txt – which contains 10 losing messages that you make up yourself.
o Your program must read in both of these text files and store the messages in two separate arrays of
strings.
o After each roll, your program must display one of these messages randomly to the user.
o NOTE: We will not cover in class how to read in text files! As part of this assignment, you must figure
this out on your own by using your textbook or an online resource/API. You can only use an online
resource for this aspect of this program!!
 HINT: You should use a Scanner object to read each text file. Use a for loop that iterates 10
times to read in each message.

-
-
i got the beginning.. but thats all >.> i wrote the rules and printed them to the console. i really dont know where to begin. help would be appreciated, you dont have to write the whole program for me(would be appreciated though) but im just lost, can you tell me what to do to get started? im just really lost. thanks guys, btw im new to this site so if this is in the wrong place im sorry!
• 02-08-2013, 05:42 PM
Fubarable
Re: can someone help me with a program?
Quote:

Originally Posted by Aziombi
so i have a program i have to write because i broke my ankle and im going to be out of school for a few days.. heres the instructions i was given.
Create a DiceGame.java which does the following:
...i got the beginning.. but thats all >.> i wrote the rules and printed them to the console. i really dont know where to begin. help would be appreciated, you dont have to write the whole program for me(would be appreciated though) but im just lost, can you tell me what to do to get started? im just really lost. thanks guys, btw im new to this site so if this is in the wrong place im sorry!

Don't even suggest that you'd appreciate it if someone wrote it for you, not unless you'd like to be banned.

But getting back to your original problem, the key is to first and foremost understand the basics of Java required of the assignment which will require study on your part, and which we cannot help you on. Next you should break down the larger assignment into the smallest steps possible, and start working on each step one at a time. Please come back if you get stuck at any particular step or if you have a specific question about a particular concept.
• 02-08-2013, 05:46 PM
Aziombi
Re: can someone help me with a program?
Oh sorry, like I said, I'm new here. I am stuck on what to do next; I dont know what the next step should be. Should I call a method or should I start by rolling the dice?
• 02-08-2013, 05:58 PM
Fubarable
Re: can someone help me with a program?
Some more specific recommendations on how to start breaking your assignment down:

• Create your winning messages and losing messages text files
• Write code to use two Scanner objects to read in these files into two String arrays.
• Write code to test out printing the Strings from each array.
• Write code to test printing out *random* Strings from each array
• Create a double money variable to hold the user's money.
• Write code to interact with the user, to present him with his selections. Don't worry about the program logic at this stage.
• Test that this code works that it prompts the user, that it gets his selection and (as a test) that it prints out his selection.
• Now put this code into a while loop that will only quit when the user selects this option and test it.
• Start working on program logic. First write code to check that the money amount the user bets is less than the money held in his money variable.
• Remove the bet amount from the money variable
• Write code to check to see if the user wins... etc...
• 02-08-2013, 06:15 PM
DarrylBurke
Re: can someone help me with a program?