版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yuxiangaaaaa/article/details/79075334
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.util.Scanner;
public class Account {
public int balance;
public int Staticbalance;
protected int AccountNumber;
protected String IDcard;
protected String Name;
protected String Adrees;
protected String password;
public Account() {
}
public Account(String IDcard, String Name, String Adress, String password,
int balance) {
this.IDcard = IDcard;
this.Name = Name;
this.Adrees = Adress;
this.password = password;
this.balance = balance;
}
public void setStaticbalance(int Staticbalance) {
this.Staticbalance = Staticbalance;
}
public void setAccountNumber() {
AccountNumber = (int) (Math.random() * 1000000000);
}
public void setBalance(int balance) {
this.balance = balance;
}
public void setIDcard(String IDcard) {
this.IDcard = IDcard;
}
public void setName(String Name) {
this.Name = Name;
}
public void setAdrees(String Adress) {
this.Adrees = Adress;
}
public void setPassword(String password) {
this.password = password;
}
public String getName() {
return Name;
}
public String getAdrees() {
return Adrees;
}
public String getIDcard() {
return IDcard;
}
public int getAccountNumber() {
return AccountNumber;
}
public int getStaticbalance() {
return Staticbalance;
}
public String getPassword() {
return password;
}
public int getbalance() {
return balance;
}
public void setbalance(int balance) {
this.balance = balance;
}
public void setAccount() throws UnsupportedEncodingException {
Scanner sc = new Scanner(System.in);
System.out.println("请输入姓名:");
String q = sc.nextLine();
setName(q);
System.out.println("请输入身份证:");
String p = sc.nextLine();
setIDcard(p);
System.out.println("请输入地址:");
String o = sc.nextLine();
o = new String(o.getBytes("GBK"),Charset.defaultCharset()); //输入中文,要转换编码格式
setAdrees(o);
setBalance(100);
setAccountNumber();
}
public void deposite() {
System.out.println("请输入你需要存的现金:");
Scanner sc = new Scanner(System.in);
int w = sc.nextInt();
System.out.println("1.活期 2.定期");
int s = sc.nextInt();
if (s == 1)
balance = balance + w;
else {
Staticbalance = Staticbalance + w;
System.out.println("最低存一年 一年内不可取");
}
}
public void withdraw() {
System.out.println("请输入你要取得钱");
Scanner sc = new Scanner(System.in);
int w = sc.nextInt();
if (balance > w)
balance = balance - w;
else
System.out.println("您的余额不足!\n您的活期为" + balance + "定期为"
+ Staticbalance);
}
}
import java.io.UnsupportedEncodingException;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws UnsupportedEncodingException {
char choise;
int i = 0;
boolean flag;//判断标识
Scanner sc = new Scanner(System.in);
Account[] array = new Account[100];
for (int n = 0; n < 100; n++) {
array[n] = new Account("asd", "asd", "asd", "asd", 1);
}
do {
System.out.println("------------------------------------------------");
System.out.println("| Welcome to the BUU IT Wisdom Bank |");
System.out.println("| What may I help you? |");
System.out.println("| 1.开户 |");
System.out.println("| 2.销户 |");
System.out.println("| 3.按姓名查询 |");
System.out.println("| 4.按账号查询 |");
System.out.println("| 5.存钱 |");
System.out.println("| 6.取钱 |");
System.out.println("------------------------------------------------");
System.out.println("");
System.out.println("| Enter choice 1-6: |");
System.out.println("");
choise=sc.next().charAt(0);
System.out.println();
switch (choise) {
case '1':
System.out.println("---1.开户---");
array[i] = new Account();
array[i].setAccount();
i++;
break;
case '2':
System.out.println("---2.销户---");
System.out.println("请输入要删除的姓名或账号:");
String t = sc.next();
flag = false;
for (int y = 0; y < 100; y++) {
if (array[y].getName().equals(t)) {
System.out.println("删除成功");
flag = true;
break;
} else {
continue;
}
}
if(flag == false){
System.out.println("找不到");
}
break;
case '3':
System.out.println("---3.按姓名查询---");
System.out.println("请输入要查找的姓名:");
String u = sc.next();
flag = false;
for (int y = 0; y < 100; y++) {
if (array[y].getName().equals(u)) {
System.out.println("查询的姓名为:"+array[y].getName());
System.out.println("您的账号为:"+array[y].getAccountNumber());
System.out.println("您的余额为"+array[y].getbalance());
System.out.println("地址为:"+array[y].getAdrees());
flag = true;
break;
} else{
continue;
}
}
if(flag == false){
System.out.println("不存在");
}
break;
case '4':
System.out.println("---4.按账号查询 ---");
System.out.println("请输入要查找的账号:");
int m = sc.nextInt();
flag = false;
for (int y = 0; y < 100; y++) {
if (array[y].getAccountNumber() == m) {
System.out.println("查询的姓名:" + array[y].getName());
System.out.println("您的账号为:" + array[y].getAccountNumber());
System.out.println("您的余额为" + array[y].getbalance());
System.out.println("地址为:" + array[y].getAdrees());
flag = true;
} else
break;
}
if(flag == false){
System.out.println("不存在");
}
break;
case '5':
System.out.println("---5.存钱---");
System.out.println("请输入您的账号:");
int qw = sc.nextInt();
for (int y = 0; y < 100; y++) {
if (array[y].getAccountNumber() == qw) {
array[y].deposite();
} else
break;
}
break;
case '6':
System.out.println("---6.取钱 ---");
System.out.println("请输入您的账号:");
Scanner qwe = new Scanner(System.in);
int qwr = qwe.nextInt();
//qwe.close();
for (int y = 0; y < 100; y++) {
if (array[y].getAccountNumber() == qwr) {
array[y].withdraw();
} else
break;
}
break;
case '7':
System.out.println("Quit Succsess");
sc.close();
break;
default:
System.out.println("illegl entry");
}
} while (choise != '7');
}
}
------------------------------------------------
| Welcome to the BUU IT Wisdom Bank |
| What may I help you? |
| 1.开户 |
| 2.销户 |
| 3.按姓名查询 |
| 4.按账号查询 |
| 5.存钱 |
| 6.取钱 |
------------------------------------------------
| Enter choice 1-6: |
1
---1.开户---
请输入姓名:
test
请输入身份证:
321122333313455532
请输入地址:
杭州市西湖区人民大道
------------------------------------------------
| Welcome to the BUU IT Wisdom Bank |
| What may I help you? |
| 1.开户 |
| 2.销户 |
| 3.按姓名查询 |
| 4.按账号查询 |
| 5.存钱 |
| 6.取钱 |
------------------------------------------------
| Enter choice 1-6: |
3
---3.按姓名查询---
请输入要查找的姓名:
test
查询的姓名为:test
您的账号为:80586447
您的余额为100
地址为:杭州市西湖区人民大道
------------------------------------------------
| Welcome to the BUU IT Wisdom Bank |
| What may I help you? |
| 1.开户 |
| 2.销户 |
| 3.按姓名查询 |
| 4.按账号查询 |
| 5.存钱 |
| 6.取钱 |
------------------------------------------------
| Enter choice 1-6: |
4
---4.按账号查询 ---
请输入要查找的账号:
80586447
查询的姓名:test
您的账号为:80586447
您的余额为100
地址为:杭州市西湖区人民大道
------------------------------------------------
| Welcome to the BUU IT Wisdom Bank |
| What may I help you? |
| 1.开户 |
| 2.销户 |
| 3.按姓名查询 |
| 4.按账号查询 |
| 5.存钱 |
| 6.取钱 |
------------------------------------------------
| Enter choice 1-6: |
5
---5.存钱---
请输入您的账号:
80586447
请输入你需要存的现金:
3
1.活期 2.定期
1
------------------------------------------------
| Welcome to the BUU IT Wisdom Bank |
| What may I help you? |
| 1.开户 |
| 2.销户 |
| 3.按姓名查询 |
| 4.按账号查询 |
| 5.存钱 |
| 6.取钱 |
------------------------------------------------
| Enter choice 1-6: |
4
---4.按账号查询 ---
请输入要查找的账号:
80586447
查询的姓名:test
您的账号为:80586447
您的余额为103
地址为:杭州市西湖区人民大道
------------------------------------------------
| Welcome to the BUU IT Wisdom Bank |
| What may I help you? |
| 1.开户 |
| 2.销户 |
| 3.按姓名查询 |
| 4.按账号查询 |
| 5.存钱 |
| 6.取钱 |
------------------------------------------------
| Enter choice 1-6: |
6
---6.取钱 ---
请输入您的账号:
80586447
请输入你要取得钱
5
------------------------------------------------
| Welcome to the BUU IT Wisdom Bank |
| What may I help you? |
| 1.开户 |
| 2.销户 |
| 3.按姓名查询 |
| 4.按账号查询 |
| 5.存钱 |
| 6.取钱 |
------------------------------------------------
| Enter choice 1-6: |
4
---4.按账号查询 ---
请输入要查找的账号:
80586447
查询的姓名:test
您的账号为:80586447
您的余额为98
地址为:杭州市西湖区人民大道
------------------------------------------------
| Welcome to the BUU IT Wisdom Bank |
| What may I help you? |
| 1.开户 |
| 2.销户 |
| 3.按姓名查询 |
| 4.按账号查询 |
| 5.存钱 |
| 6.取钱 |
------------------------------------------------
| Enter choice 1-6: |
2
---2.销户---
请输入要删除的姓名或账号:
test
删除成功
------------------------------------------------
| Welcome to the BUU IT Wisdom Bank |
| What may I help you? |
| 1.开户 |
| 2.销户 |
| 3.按姓名查询 |
| 4.按账号查询 |
| 5.存钱 |
| 6.取钱 |
------------------------------------------------
| Enter choice 1-6: |
7
Quit Succsess