Java怎么判断从键盘上输入字符
https://jingyan.baidu.com/article/acf728fd72a9b8f8e510a309.html
Java 编程错误父类与子类的构造函数继承问题
java数组与字符串相互转换、整型与字符串相互转换【详解】
https://www.cnblogs.com/highshao/p/5436186.html
import java.util.Scanner;
import java.io.*;
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("输入你的当前账户");
Scanner readern = new Scanner(System.in);
int n = readern.nextInt();
System.out.println("当前账户余额:100000.00元");
System.out.println("请选择功能:");
System.out.println("1.存钱 2. 取钱 0. 退出");
Scanner readernum = new Scanner(System.in);
int num = readernum.nextInt();
if(num>2)
System.out.println("选择错误!");
else if(num==0)
System.out.println("再见!");
else if(num==1) {
System.out.println("请输入存款金额:");
Scanner reader = new Scanner(System.in);
String str= reader.nextLine();
boolean isNum = str.matches("[0-9]+");
if(!isNum)
System.out.println("输入有误!");
else {
int sum = Integer.valueOf(str).intValue()+100000;
System.out.println("当前账户余额:"+sum);
}
}
else if(num==2) {
System.out.println("请输入取款金额:");
Scanner reader = new Scanner(System.in);
String str= reader.nextLine();
int sum = Integer.valueOf(str).intValue();
if(sum>100000)
System.out.println("余额不足!");
else {
sum=100000-sum;
System.out.println("当前账户余额:"+sum);
}
}
}
}