MyException - 我的异常网
当前位置:我的异常网» J2SE » java 初学者 为什么输入不能第二个数

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

www.MyException.Cn  网友分享于:2013-12-18  浏览:8次
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");
        }

    }
}

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有