日期:2014-05-20  浏览次数:20730 次

java 菜鸟 为什么输入不能第二个数?
import java.util.Scanner;
public class XingDai 
{
public static void main(){

Scanner input = new Scanner(System.in);
int leftmoney;
int salary;
int give;
int credit;
System.out.println("Enter leftMoney:");
leftmoney = input.nextInt();
System.out.println("Enter salary:");
salary = input.nextInt();
System.out.println("Enter give:");
give = input.nextInt();
credit = leftmoney + salary -give;
while(credit < 0){

System.out.println("Credit limit exceeded");}

}
}


------解决方案--------------------
实在不懂你的程序想干啥
Java code
import java.util.Scanner;

public class Test {

    public static void main(String[] arg) {

        Scanner input = new Scanner(System.in);
        int leftmoney;
        int salary;
        int give;
        int credit;
        System.out.println("Enter leftMoney:");
        leftmoney = input.nextInt();
        System.out.println("Enter salary:");
        salary = input.nextInt();
        System.out.println("Enter give:");
        give = input.nextInt();
        credit = leftmoney + salary - give;
        while (credit < 0) {

            System.out.println("Credit limit exceeded");
        }

    }
}