当前位置: 代码迷 >> J2SE >> java 初学者 为什么输入不能第二个数
  详细解决方案

java 初学者 为什么输入不能第二个数

热度:262   发布时间:2016-04-24 18:09:52.0
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");        }    }}
  相关解决方案