Java代码银行业务办理 java做银行项目需要懂哪些业务

使用JAVA编写一个简单的银行存取款程序package com.lw.thread;
/*
银行账户类Account(不能透支),
包含账号id(10~16位数字),密码password(6位数字),户主姓名name,余额balence
*/
public class Account {
private String id;
private int password;
private String name;
private double balence;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getPassword() {
return password;
}
public void setPassword(int password) {
this.password = password;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getBalence() {
return balence;
}
public void setBalence(double balence) {
this.balence = balence;
}
/*
* 默认构造账户信息为:1111111111111111,666666,钱三多,888888.88 。
*/
public Account() {
super();
this.id = "1111111111111111";
this.password = 666666;
this.name = "钱三多";
this.balence = 888888.88;
}
/*
* 另一个构造方法带4个参数分别初始化4个属性(带数据有效性验证) 。
*/
public Account(String id, int password, String name, double balence) {
this.id = id;
this.password = password;
this.name = name;
this.balence = balence;
}
/*
* 查询余额
*/
public static double selectMoney(Account account) {
return account.getBalence();
}
/*
* 存钱
*/
public static String setMoney(Account account, double balence) {
if (balence0) {
return "存钱失败,请正确放入!";
}
double d = balenceaccount.getBalence();
account.setBalence(d);
return "您存入了"balence"元,现账户余额为 "d;
}
/*
* 取钱
*/
public static String getMoney(Account account, double balence) {
double d = account.getBalence();
if (balenced) {
return "您的余额不足!";
}
account.setBalence(d - balence);
return "您取出了"balence"元 , 现账户余额为 "account.getBalence();
}
}
在java里有没有办理银行业务的if语句的例子import java.util.Scanner;
public class Bank {
private static int a;
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
String dayNum;
System.out.println("请输入星期数(1 - 7):");
dayNum = s.nextLine();
try {
a = Integer.parseInt(dayNum);
} catch (NumberFormatException e) {
System.out.println("数字格式有误 。");
return;
}
if (a = 1a = 5)
System.out.println("今天既办理公司业务Java代码银行业务办理,也办理个人业务 。");
else if (a == 6 || a == 7)
System.out.println("今天只办理个人业务 。");
else
System.out.println("无效Java代码银行业务办理的天数 。");
s.close();
}
}
运行结果如下:
用java编写一个银行新用户现金业务办理程序public class Account {
protected String accId;
protected String name;
protected double money;
public Account (String accId,String name){
this(accId,name,0);
}
public Account (String accId,String name,double money){
this.accId = accId;
this.name = name;
this.money = money;
}
public void saveMoney(double money){
if(money = 0){
System.out.println("存款金额必须大于0");
}
this.money= money;
System.out.println("存款成功");
}
public double getMoney(double money){
if(money = 0){
System.out.println("取款金额必须大于0");
return 0;
}
if(this.money = money){
System.out.println("余额不足Java代码银行业务办理,无法取款");
return 0;
}
this.money -= money;
System.out.println("取款成功");
return money;
}
public double getBalance(){
return this.money;
}
protected double getOverdraft(){
return 0;
}
// 实现了equals方法Java代码银行业务办理,list比较时才能正确
@Override
public boolean equals(Object obj) {
if(obj == null){
return false;
}
if(this == obj){
return true;
}
if(obj instanceof Account){
return this.accId.equals(((Account)obj).accId);
}
return false;
}
@Override
public String toString() {
return "账户="accId",名字="name",余额="money;
}
}
public class Bank {
// Account实现了equals方法,list查找时才能正确
private ListAccount usersAccounts;
public Bank() {
usersAccounts = new ArrayListAccount();
}
public void addAccount(Account account) {
if (usersAccounts.contains(account)) {
System.out.println("添加失败 , 不能添加同样Java代码银行业务办理的账户");
return;
}
usersAccounts.add(account);
}
public boolean delAccount(Account account) {
return usersAccounts.remove(account);
}
public boolean delAccount(String accId) {
return delAccount(new Account(accId, null));
}
public boolean existAccount(Account account) {
return usersAccounts.contains(account);
}
public boolean existAccount(String accId) {
return existAccount(new Account(accId, null));
}
public Account getAccount(String accId){
return usersAccounts.get(usersAccounts.indexOf(new Account(accId, null)));
}
public double getAllMoney() {
// 不考虑是否溢出 , 只是把所有用户余额相加
double result = 0;
for (Account account : usersAccounts) {
result= account.getBalance();
}
return result;
}
public double getAllOverdraft() {
// 不考虑是否溢出
double result = 0;
for (Account account : usersAccounts) {
result= account.getOverdraft();
}
return result;
}
public int getAccountNum() {
return usersAccounts.size();
}
public int getCreditAccountNum() {
int num = 0;
for (Account account : usersAccounts) {
// instanceof 性能没有简单的方法快 。
if (account instanceof CreditAccount) {
num;
}
}
return num;
}
public int getSavingAccountNum() {
int num = 0;
for (Account account : usersAccounts) {
if (account instanceof SavingAccount) {
num;
}
}
return num;
}
public ListAccount getAllAccount() {
return usersAccounts;
}
}
public class CreditAccount extends Account{
private double overdraft;
public CreditAccount(String accId,String name){
super(accId, name);
this.overdraft = 1000;
}
public CreditAccount(String accId,String name,double money){
this(accId, name,money,1000);
}
public CreditAccount(String accId,String name,double money,double overdraft){
super(accId, name,money);
this.overdraft = overdraft;
}
@Override
public double getMoney(double money) {
if(money = 0){
System.out.println("取款金额必须大于0");
return 0;
}
if(this.moneyoverdraft = money){
System.out.println("余额不足 , 无法取款");
return 0;
}
this.money -= money;
System.out.println("取款成功");
return money;
}
@Override
public double getOverdraft(){
return overdraft;
}
@Override
public String toString() {
return "账户="accId",名字="name",余额="money",透支="overdraft;
}
}
public class SavingAccount extends Account {
public SavingAccount(String accId, String name) {
super(accId, name);
}
public SavingAccount(String accId, String name, double money) {
super(accId, name, money);
}
@Override
public double getMoney(double money) {
return super.getMoney(money);
}
@Override
public double getOverdraft() {
return super.getOverdraft();
}
}
public class Test {
private static Bank bank = new Bank();
public static void main(String[] args) {
Test.genAccount();
// 开户
Account a1 = new CreditAccount("1", "1", 200, 2000);
Account a2 = new SavingAccount("2", "2", 300);
Account a3 = new SavingAccount("3", "3", 400);
Account a4 = new CreditAccount("4", "4", 500, 2000);
Account a5 = new CreditAccount("4", "5", 600, 2000); // 帐号4重
bank.addAccount(a1);
bank.addAccount(a2);
bank.addAccount(a3);
bank.addAccount(a4);
bank.addAccount(a5);
showNowAccount();
// 销户
bank.delAccount("1");
bank.delAccount("2");
showNowAccount();
// 存款
if(bank.existAccount("3")){
Account acc= bank.getAccount("3");
acc.saveMoney(100);
}
showNowAccount();
// 取款
if(bank.existAccount("3")){
Account acc= bank.getAccount("3");
System.out.println("余额="acc.getBalance());
acc.getMoney(100);
System.out.println("余额="acc.getBalance());
acc.getMoney(1000);
System.out.println("余额="acc.getBalance());
}
if(bank.existAccount("4")){
Account acc= bank.getAccount("4");
System.out.println("余额="acc.getBalance());
acc.getMoney(100);
System.out.println("余额="acc.getBalance());
acc.getMoney(1000);
System.out.println("余额="acc.getBalance());
acc.getMoney(10000);
System.out.println("余额="acc.getBalance());
}
System.out.println(bank.getAccountNum());
System.out.println(bank.getAllMoney());
System.out.println(bank.getAllOverdraft());
System.out.println(bank.getCreditAccountNum());
System.out.println(bank.getSavingAccountNum());
}
public static void genAccount(){
String s = "1000 0000 0000 000";
Account a = null;
for(int i = 1; i11; i){
if((i2) == 0){
a = new CreditAccount(sString.valueOf(i), "账户"String.valueOf(i));
} else {
a = new SavingAccount(sString.valueOf(i), "账户"String.valueOf(i));
}
bank.addAccount(a);
}
}
public static void showNowAccount(){
for(Account account : bank.getAllAccount()){
System.out.println(account);
}
}
}
Java课程设计,模拟银行存取业务,按照这个流程图去做,其实最主要的是求画圈的部分怎么写和它的方法 。请点击输入图片描述
package com.greatwall.business.controller;
import java.math.BigDecimal;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author xysddjyt
* @since 2020/6/16 15:06
*/
public class BankTest {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
// 余额(单位:分)
Long BALANCE = 10000000L;
// 卡号
String card = "001";
// 密码
String password = "123456";
String inputCard = new String();
String inputPassword = new String();
String quit = new String();
while (true) {
System.out.println("\n欢迎来到网上银行办理存取款业务!");
System.out.println("请输入银行卡号和银行卡密码进行登录!");
while (true) {
System.out.print("请输入银行卡号(按q退出): ");
inputCard = scan.nextLine();
quit = inputCard;
if (inputCard.equals("q")) {
break;
}
if (!inputCard.equals(card)) {
System.out.print("您输入银行卡号不正确,请重新输入 ");
continue;
}
break;
}
if (quit.equals("q")) {
continue;
}
while (true) {
System.out.print("请输入银行卡密码(按q退出): ");
inputPassword = scan.nextLine();
quit = inputPassword;
if (inputPassword.equals("q")) {
break;
}
if (!inputPassword.equals(password)) {
System.out.print("您输入银行卡密码不正确,请重新输入 ");
continue;
}
break;
}
if (quit.equals("q")) {
continue;
}
System.out.print("登录成功,当前登录的账户名:"inputCard);
String type = "4";
while (!type.equals("0")) {
System.out.print("\n您当前的余额为:"money(BALANCE)"元");
System.out.print("\n请选择操作类型 。(存款:1;取款:2 ;余额:3;退出:0)\n");
type = scan.nextLine();
switch (type) {
case "1": {
System.out.print("请输入您的存款金额(元):");
String chageNumber = scan.nextLine();
if (!isPositiveInteger(chageNumber)) {
System.out.print("请输入正确的存款金额!");
continue;
}
BALANCE = Long.valueOf(chageNumber) * 100BALANCE;
continue;
}
case "2": {
System.out.print("请输入您的取款金额(元):");
String chageNumber = scan.nextLine();
if (!isPositiveInteger(chageNumber)) {
System.out.print("请输入正确取款金额!");
continue;
}
BALANCE = BALANCE - Long.valueOf(chageNumber) * 100;
continue;
}
case "3": {
System.out.print("您当前的余额为:"money(BALANCE)"元\n");
continue;
}
default: {
continue;
}
}
}
}
}
private static boolean isMatch(String regex, String orginal) {
if (orginal == null || orginal.trim().equals("")) {
return false;
}
Pattern pattern = Pattern.compile(regex);
Matcher isNum = pattern.matcher(orginal);
return isNum.matches();
}
// 判断数据是否为正整数
public static boolean isPositiveInteger(String orginal) {
return isMatch("^\\ {0,1}[1-9]\\d*", orginal);
}
// 分转元 , 转换为bigDecimal在toString
public static String money(Long money) {
return BigDecimal.valueOf(money).divide(new BigDecimal(100)).toString();
}
}
【Java代码银行业务办理 java做银行项目需要懂哪些业务】关于Java代码银行业务办理和java做银行项目需要懂哪些业务的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

    推荐阅读