I am stuck when it comes to writing this code. Everything I have had to do was an easy walk through, but know we are told to use psedocode to begin this before we actually write the application.
Create a lottery game application. Generate three random numbers, each between 0 and 9. Allow the user to guess three numbers. Compare cah of the user's guesses to the three random numbers and display a message that includes the user's guesses, the randomly determined three-digit number, and the amount of money the user has won as follows:
any one matching: 10$
two matching: 100$
three matching, not in order: 1,000$
three matching: 1,000,000$
no matches: 0
Make certain that your application accommodates repeating digits. For example, if a user guesses 1, 2, and 3, and the randomly generated digits are 1, 1, and 1, do not give the user credit for three correct guesses - just one.
When you post code, be sure to UseCodeTags to keep it readable.
I still seem to be able to write letters and int when I run it.
Also, read the methods for Random here: http://docs.oracle.com/javase/6/docs/api/java/util/Random.html
That should help you figure out how to generate the random numbers internally.
I thought I was alone out there with these questions. It is very nice to know that I can push myself to get these done without just walking away.
David Godwin wrote:I have a few sketches by hand, but this is just Introduction to programming. I see ahead that I can work on arrays and loops further on in the text, but I have to work this out with if if...else && and ||. We covered switch method and Conditional and NOT operators.
That still doesn't negate the use of pseudocode. If anything, you should focus more on writing your pseudocode that explains the logic behind how you plan on tackling this assignment, rather than worrying about the syntax. If the logic is sound, the rest becomes a lot easier. So instead of posting code, why don't you focus on posting your pseudocode explaining the logic involved in completing this assignment. Assume that you have already parsed each of the 3 numbers from the user input and then try to figure out the pseudocode for getting the necessary output.
Also, if you haven't done loops yet, then checking the input for invalid input is not going to be very fruitful. As it stands, even when you detect a wrong input (number not between 0-9), the program proceeds to take the next input. You might be better off printing an Error message and using System.exit(0) to terminate the program. You could use loops to continue attempting an input till it is acceptable...but this is not so important. As I suggested...focus on the more important tasks at hand at try to write out the pseudocode here. If you are stuck in a specific section, folks might be able to assist you.