Java在继续之前需要两次输入

问题描述

import java.util.Random;
import java.util.Scanner;
import java.util.Timer;



public class RollingDice {
static int interval;
static Timer timer;
//(String[] args)
    public static void main(String[] args) {
        
        Scanner myBet = new Scanner(System.in);
        while (true) {
        System.out.println("How much are you wanting to bet? ");
        String input = myBet.next();
        
        int intInputValue = 0;
        try {
                intInputValue = Integer.parseInt(input);
                break;
        } catch (NumberFormatException ne) {
            System.out.println("This is not a bet ya tard. ");
                                           }
                    }
        int betAmmount = myBet.nextInt();
                    
        System.out.println("you are risking - $" + betAmmount);
        
        
        Random diceFace = new Random();
            int d = diceFace.nextInt(6) + 1;
        
        System.out.println("Rolled a " + d);
        
        Random opDice = new Random();
            int o = opDice.nextInt(6) + 1;
            
        System.out.println("the Op's Rolled a " + o);
        
        if (d < o) {
            System.out.println("Damn you got finessed out of " + "$" + betAmmount );
                   }
        else if (d == o) {
            System.out.println("Tied");
                         }
        else {
            System.out.println("Nice win " + "$" + betAmmount * 2);
             }
        

    }

}

到目前为止,这是我进行简单骰子掷骰的结果,但是每次我运行并输入数字时,它都不会超出输入,除非我再次输入数字,甚至不必相同作为第一个数字。Example of it using the 2nd input

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)