58,454
社区成员
发帖
与我相关
我的任务
分享
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
char choise;
int size;
Scanner sc = new Scanner(System.in);
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();
Account[] array=new Account[100];
int i=0;
switch (choise) {
case '1':
for (int n=0;n<100;n++)
{
array[n]=new Account("asd","asd","asd","asd",1);
}//我写的初始化遍历
array[i]=new Account();
array[i].setAccount();
i++;
break;
case'2':
System.out.println("请输入要删除的姓名或账号:");
Scanner sd=new Scanner(System.in);
String t=sd.nextLine();
sd.close();
for (int n=i;n<100;n++)
{
array[n]=new Account("asd","asd","asd","asd",1);
}//调用那个查询那个就出现空指针异常 加上这个就出现
// Exception in thread "main" java.util.NoSuchElementException: No line found at java.util.Scanner.nextLine
for (int y=0;y<=100;y++)
{
if (array[y].getName().equals(t)) {
System.out.println("删除成功");
}else {
System.out.println("找不到");
break;
}
}
case'3':
System.out.println("请输入要查找的姓名:");
Scanner ss=new Scanner(System.in);
String u=ss.nextLine();
ss.close();
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();
}
else
break;
}
System.out.println("不存在");
break;
case'4':
System.out.println("请输入要查找的账号:");
Scanner sg=new Scanner(System.in);
int m=sg.nextInt();
sg.close();
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();
}
else
break;
}
System.out.println("不存在");
break;
case'5':
System.out.println("请输入您的账号:");
Scanner sqw=new Scanner(System.in);
int qw=sqw.nextInt();
sqw.close();
for (int y=0;y<=100;y++)
{
if (array[y].getAccountNumber()==qw)
{
array[y].deposite();
}
else
break;
}
break;
case'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].deposite();
}
else
break;
}
case'7':
System.out.println("Quit Succsess");
break;
default:System.out.println("illegl entry" );
}
} while (choise != '7');
}
}
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(){
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(){
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();
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);
}
}
------------------------------------------------
| 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
import java.io.UnsupportedEncodingException;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws UnsupportedEncodingException {
char choise;
//int size;
int i = 0;
boolean flag;//判断标识
Scanner sc = new Scanner(System.in);
Account[] array = new Account[100];
for (int n = 0; n < 100; n++) {//初始化放在最开始,不能放在do语句里面,不然每次开户都重新初始化数据了
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("请输入要删除的姓名或账号:");
// Scanner sd = new Scanner(System.in);
// String t = sd.nextLine();
String t = sc.next();
//sd.close();
// for (int n = i; n < 100; n++) //这里是多余的,不能重新初始化了,不然开户的数据就清除了
// {
// array[n]=new Account("asd","asd","asd","asd",1);
// }//调用那个查询那个就出现空指针异常 加上这个就出现
// Exception in thread "main"
// java.util.NoSuchElementException: No line found at
// java.util.Scanner.nextLine
flag = false;
for (int y = 0; y < 100; y++) {
if (array[y].getName().equals(t)) {
System.out.println("删除成功");
flag = true;
break;
} else {
// System.out.println("找不到");
// break;
continue;
}
}
if(flag == false){
System.out.println("找不到");
}
break;
case '3':
System.out.println("---3.按姓名查询---");
System.out.println("请输入要查找的姓名:");
// Scanner ss = new Scanner(System.in);
// String u = ss.nextLine();
String u = sc.next();
//ss.close();
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("请输入要查找的账号:");
// Scanner sg = new Scanner(System.in);
// int m = sg.nextInt();
int m = sc.nextInt();
flag = false;
//sg.close();
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("请输入您的账号:");
// Scanner sqw = new Scanner(System.in);
// int qw = sqw.nextInt();
int qw = sc.nextInt();
//sqw.close();
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');
}
}
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();
}
package com.yx.test;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
char choise;
int size;
int i = 0;
boolean flag;
Scanner sc = new Scanner(System.in);
Account[] array = new Account[100];
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':
for (int n = 0; n < 100; n++) {
array[n] = new Account("asd", "asd", "asd", "asd", 1);
}// 我写的初始化遍历
array[i] = new Account();
array[i].setAccount();
i++;
break;
case '2':
System.out.println("请输入要删除的姓名或账号:");
// Scanner sd = new Scanner(System.in);
// String t = sd.nextLine();
String t = sc.next();
//sd.close();
// for (int n = i; n < 100; n++) //这里是多余的,不能重新初始化了,不然开户的数据就清除了
// {
// array[n]=new Account("asd","asd","asd","asd",1);
// }//调用那个查询那个就出现空指针异常 加上这个就出现
// Exception in thread "main"
// java.util.NoSuchElementException: No line found at
// java.util.Scanner.nextLine
flag = false;
for (int y = 0; y < 100; y++) {
if (array[y].getName().equals(t)) {
System.out.println("删除成功");
flag = true;
break;
} else {
// System.out.println("找不到");
// break;
continue;
}
}
if(flag == false){
System.out.println("找不到");
}
break;
case '3':
System.out.println("请输入要查找的姓名:");
// Scanner ss = new Scanner(System.in);
// String u = ss.nextLine();
String u = sc.next();
//ss.close();
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("请输入要查找的账号:");
// Scanner sg = new Scanner(System.in);
// int m = sg.nextInt();
int m = sc.nextInt();
//sg.close();
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();
} else
break;
}
System.out.println("不存在");
break;
case '5':
System.out.println("请输入您的账号:");
// Scanner sqw = new Scanner(System.in);
// int qw = sqw.nextInt();
int qw = sc.nextInt();
//sqw.close();
for (int y = 0; y < 100; y++) {
if (array[y].getAccountNumber() == qw) {
array[y].deposite();
} else
break;
}
break;
case '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].deposite();
} 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
请输入姓名:
11
请输入身份证:
11
请输入地址:
11
------------------------------------------------
| Welcome to the BUU IT Wisdom Bank |
| What may I help you? |
| 1.开户 |
| 2.销户 |
| 3.按姓名查询 |
| 4.按账号查询 |
| 5.存钱 |
| 6.取钱 |
------------------------------------------------
| Enter choice 1-6: |
3
请输入要查找的姓名:
11
查询的姓名为:
您的账号为:
您的余额为
地址为:
------------------------------------------------
| Welcome to the BUU IT Wisdom Bank |
| What may I help you? |
| 1.开户 |
| 2.销户 |
| 3.按姓名查询 |
| 4.按账号查询 |
| 5.存钱 |
| 6.取钱 |
------------------------------------------------
| Enter choice 1-6: |
2
请输入要删除的姓名或账号:
11
删除成功
------------------------------------------------
| Welcome to the BUU IT Wisdom Bank |
| What may I help you? |
| 1.开户 |
| 2.销户 |
| 3.按姓名查询 |
| 4.按账号查询 |
| 5.存钱 |
| 6.取钱 |
------------------------------------------------
| Enter choice 1-6: |
4
请输入要查找的账号:
111
不存在
------------------------------------------------
| Welcome to the BUU IT Wisdom Bank |
| What may I help you? |
| 1.开户 |
| 2.销户 |
| 3.按姓名查询 |
| 4.按账号查询 |
| 5.存钱 |
| 6.取钱 |
------------------------------------------------
| Enter choice 1-6: |
5
请输入您的账号:
111
------------------------------------------------
| Welcome to the BUU IT Wisdom Bank |
| What may I help you? |
| 1.开户 |
| 2.销户 |
| 3.按姓名查询 |
| 4.按账号查询 |
| 5.存钱 |
| 6.取钱 |
------------------------------------------------
| Enter choice 1-6: |
6
请输入您的账号:
111
------------------------------------------------
| 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