d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Need Some Java Help
Add Reply New Topic New Poll
Member
Posts: 534
Joined: Feb 8 2011
Gold: 53.30
Feb 11 2013 12:11pm
Working on a project for a class. The project is to make a game, that starts the user with $10.00 . There are 6 options that are to be prompted.. even, odd, fibonacci, double, exact, and done. These options need to be prompted before each select, as well as the new total after the roll of dice happen. If done is chosen, the game ends.. There are different amounts attached to each bet. The game also ends if user reaches $0.00. The game itself is calculated by rolling 2 dices, and adding the numbers together.

So, my issues: I don't know how to attach the choices, such as even - odd - double - exact with anything. I am just staring at these words wondering what I need to make them. I understand how the whole program works, its just the actual programming itself and using the correct wording etc...

So far I have the dice roll working, and have a column of println's setup to display the choices and the fixed bet amounts. I was even thinking about, if possible, to make some dialog box that has these choices and fixed amounts, with the option to click on one, but I am still in the same boat. I dont know how to, once the user decides, to attach whatever they chose to an actual code to run something.
For ex: if someone chose even, I would more than likely use the sum of the two dice, take the remainder, set it to 0, return true with adding $.50. But if false, than subtract the $.50.

I am a true noob at java code, so any help would be appreciated..
Im not looking for anyone to do the project, just some advice or tips that may help..

if any more info is needed I can pm them.

This post was edited by Malexir on Feb 11 2013 12:12pm
Member
Posts: 2,775
Joined: May 17 2008
Gold: 410.74
Feb 16 2013 06:40am
Use a scanner to read input, I don't really understand the game model so please post your code so far
Member
Posts: 4,605
Joined: Sep 15 2011
Gold: 9,464.00
Feb 16 2013 09:53am
here's a simple piece of code that uses the user input to decide what to do:

Code

Scanner sc = new Scanner(System.in);
int i = sc.nextInt("Please enter either 1 or 2.");

if (i == 1) {
 System.out.println("You have entered a 1.");
} else if (i == 2) {
 System.out.println("You have entered a 2.");
} else {
 System.out.println("You have entered the wrong number.");
}
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll