帮我写一个基于Java语言实现模拟银行存取款业务系统代码
时间: 2023-03-26 15:01:59 浏览: 105
好的,我可以回答这个问题。以下是一个基于Java语言实现模拟银行存取款业务系统的代码:
```
import java.util.Scanner;
public class BankSystem {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double balance = ;
while (true) {
System.out.println("请选择操作:");
System.out.println("1. 存款");
System.out.println("2. 取款");
System.out.println("3. 查询余额");
System.out.println("4. 退出");
int choice = input.nextInt();
switch (choice) {
case 1:
System.out.println("请输入存款金额:");
double deposit = input.nextDouble();
balance += deposit;
System.out.println("存款成功,当前余额为:" + balance);
break;
case 2:
System.out.println("请输入取款金额:");
double withdraw = input.nextDouble();
if (withdraw > balance) {
System.out.println("余额不足,取款失败");
} else {
balance -= withdraw;
System.out.println("取款成功,当前余额为:" + balance);
}
break;
case 3:
System.out.println("当前余额为:" + balance);
break;
case 4:
System.out.println("感谢使用本系统,再见!");
System.exit();
default:
System.out.println("无效的操作,请重新选择");
}
}
}
}
```
以上就是一个基于Java语言实现模拟银行存取款业务系统的代码,希望能对您有所帮助。
阅读全文
相关推荐
![7z](https://img-home.csdnimg.cn/images/20241231044736.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231044736.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231045021.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)