This code from the book works fine until I try to add my own code(of course) to make the program ask if I want to continue(Which was part of an earlier lesson). Everything works fine untill it comes to the point where I want it to ask if you want to play again. In the terminal when I run it is just sits there with no prompt after it tells me how much is left in the bank.
I'm guessing the code for the most part is OK, it is the layout of the code. Can someone explaine why it is hanging up in the Terminal after it tells me how much is left in the bank? What is stopping it from continuing down to the next line of code asking if I want to play again?
Thanks,
-Lars
I'm guessing the code for the most part is OK, it is the layout of the code. Can someone explaine why it is hanging up in the Terminal after it tells me how much is left in the bank? What is stopping it from continuing down to the next line of code asking if I want to play again?
Code:
import java.util.Scanner;
public class bet
{
static Scanner sc = new Scanner(System.in);
public static void main(String [] args)
{
int bank = 1000;
int bet;
System.out.println("You can bet between 1 and " + bank);
do
{
System.out.print("Place your bet ");
bet = sc.nextInt();
}
while ( (bet <= 0 ) || (bet > bank) );
int r = (bank - bet);
System.out.println("Your money is still good and you still have " + r + " in the bank");
{
String input = ("Y");
while (input.equalsIgnoreCase("Y"));
{
System.out.print("Would you like to play again (Y or N)");
input = sc.next();
}
System.out.println("See ya");
}
}
}
Thanks,
-Lars