package sample;

import java.io.IOException;
import java.io.Serializable;
import java.util.Scanner;
import java.util.ArrayList;

public class Account
{

private String accountID;
private String accountname;
private String operatedate;
private int operatetype;
private String accountpassword;
private int accountbalance;
private int amount;

public Account(String aaccountID, String aaccountname,String aoperatedate,int aoperatetype,String aaccountpassword,int aaccountbalance,int aamount)
{
accountID=aaccountID;
accountname=aaccountname;
operatedate=aoperatedate;
operatetype=aoperatetype;
accountpassword=aaccountpassword;
accountbalance=aaccountbalance;
amount=aamount;
}
public String getaccountID() {return accountID;}
public void setaccountID(String aaccountID) {accountID=aaccountID;}
public String getaccountname() {return accountname;}
public void setacccountname(String aaccountname) {accountname=aaccountname;}
public String getoperatedate() {return operatedate;}
public void setoperatedate(String aoperatedate) {operatedate=aoperatedate;}
public int getoperatetype() {return operatetype;}
public void setoperatetype(int aoperatetype) {operatetype=aoperatetype;}
public String getaccountpassword() {return accountpassword;}
public void setaccountpassword(String aaccountpassword) {accountpassword=aaccountpassword;}
public int getaccountbalance() {return accountbalance;}
public void setaccountbalance(int aaccountbalance) {accountbalance=aaccountbalance;}
public int getamount() {return amount;}
public void setamount(int aamount) {amount=aamount;}

public static void main(String[] args) {

String user = "zhan";//用户名
String pwd = "123";//密码
float money = 100f ;//初始余额
welcome();
if (login(user,pwd)){
//登录成功
@SuppressWarnings("resource")
Scanner sc = new Scanner(System.in);
while (true){
System.out.println("1、查询 2、存款 3、取款 4、修改密码 5、退出");
switch (sc.nextInt()){
case 1 :
searchMoney(money);
break;
case 2 :
money += saveMoney();
break;
case 3 :
money -= getMoney(money);
break;
case 4 :
pwd = changePwd(pwd);
break;
case 5 : System.exit(0); break;
default :;break;
}
}
}else{
//登录失败
//System.out.println("登录失败,系统退出!");
System.exit(0);
}
}

/**
* 欢迎登陆界面 *
*
* * */
public void FileWiter()
{
File file = null;
FileWriter fw = null;
file = new File("D:\\eclipse\\安装\\accountinformation.txt");
try {
if (!file.exists()) {
file.createNewFile();
}
fw = new FileWriter(file);
for(int i = 1;i <=5;i++){
fw.write("20173528 zhangsan 2018-09-20 0 000000 1000 0");//向文件中写内容
fw.write("20173529 lisi 2018-09-20 0 000000 1000 0");
fw.write("20173530 wangwu 2018-09-20 0 000000 1000 0");
fw.write("20173531 zhaoliu 2018-09-20 0 000000 1000 0");
fw.write("20173532 qinqi 2018-09-20 0 000000 1000 0");
fw.flush();
}
System.out.println("写数据成功!");
} catch (IOException e) {
e.printStackTrace();
}finally{
if(fw != null){
try {
fw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

}
public static void welcome (){
System.out.println("***********************");
System.out.println("——欢迎登陆———");
System.out.println("***********************");
System.out.println("***********************");
System.out.println("***********************");
}
/**
* 登陆--检测用户名和密码
*
* */
public static boolean login (String user ,String pwd){
@SuppressWarnings("resource")
Scanner sc = new Scanner (System.in);

for (int i = 3 ;i>0;i--){
System.out.println("请输入用户名:");
String checkUser = sc.next();//用户输入 用户名
System.out.println("请输入密码:");
String checkPwd = sc.next();//用户输入 密码
// .equals()匹配字符串
if (user.equals (checkUser) && pwd.equals (checkPwd) ){
System.out.println("登陆成功!");
return true ;
}else {
if ( i ==1 ){
System.out.println("你的卡被吞!!找相关人员");
return false ;
}
System.out.println("用户名或密码错误!今日剩余次数:"+ (i-1));
}
}
return false ;
}
/**
*查询余额
*
* */
public static void searchMoney (float money){
System.out.println("你的余额为"+money);
}
/**
*存款
*
* */
public static float saveMoney (){
System.out.println("请输入存款金额:");
@SuppressWarnings("resource")
Scanner sc = new Scanner (System.in);
float saveMoney = sc.nextFloat();

if (saveMoney > 10000){
System.out.println("单次最大存款金额为1000.0元");
saveMoney=0;
}else if (saveMoney < 0){
System.out.println("不能存负数的钱!!");
saveMoney=0;
}else if (saveMoney %100!= 0){
System.out.println("不能存零钱!!");
saveMoney=0;
}else{
System.out.println("存款成功!");
}
return saveMoney ;
}
/**
*取款
*
* */
public static float getMoney (float money){
System.out.println("请输入取款金额:");
@SuppressWarnings("resource")
Scanner sc = new Scanner (System.in);
float getMoney = sc.nextFloat();

if (getMoney > 10000){
System.out.println("单次最大取款金额为1000.0元");
getMoney=0;
}else if (getMoney < 0){
System.out.println("不能取负数的钱!!");
getMoney=0;
}else if (getMoney %100!= 0){
System.out.println("不能取零钱!!");
getMoney=0;
}else if (money <getMoney ){
System.out.println("余额不足!!");
getMoney=0;
}else {
System.out.println("取款成功!");
}
return getMoney ;
}

/**
*修改密码
*
* */
public static String changePwd(String oldPwd) {
System.out.println("请输入旧密码:");
@SuppressWarnings("resource")
Scanner sc = new Scanner (System.in);
String pwd = sc.next();

if (pwd.equals(oldPwd)){
//老密码正确;
System.out.println("请输入新密码:");
String newPwd_1= sc.next();
System.out.println("请再次输入新密码:");
String newPwd_2= sc.next();
if (newPwd_1.equals(newPwd_2)){
System.out.println("密码修改成功!");
return newPwd_1 ;
}else{
System.out.println("两次密码不一致,请重新修改!");
return oldPwd ;
}
}else {
System.out.println("旧密码输入错误,请重新修改!");
}
return oldPwd ;
}
}

Java开学测试源代码的更多相关文章

  1. Java开学测试

    这次开学测试要求做一个信息系统,该系统完成学生成绩录入,修改,计算学分积点和查询学生成绩的简单功能. 下面是我写的代码 //信1805-3班 20183641 赵树琪 package test; im ...

  2. JAVA 开学测试

    package StudentScore; public class ScoreInformation { String stunumber; //学号 String name; //姓名 doubl ...

  3. Java开学测试感想

    开学第一堂课就是测试,测试暑假的自学成果,老师说试卷适当提高了难度,所以允许查书和使用网络查询,经过近三个钟头的努力奋斗和痛苦挣扎,我只完成了一小部分的代码,只有简单的set()get()函数,以及简 ...

  4. Java开学测试-学生成绩管理系统

    题目: 1.定义 ScoreInformation 类,其中包括七个私有变量(stunumber, name, mathematicsscore, englishiscore,networkscore ...

  5. java开学考试有感以及源码

    一.感想 Java开学测试有感 九月二十号,王老师给我们上的第一节java课,测试. 说实话,不能说是十分有自信,但还好,直到看见了开学测试的题目,之前因为已经做过了王老师发的16级的题目,所以当时还 ...

  6. JAVA语言课堂测试源代码及使用截图

    1源代码 第一部分 package 开学测试.java;class ScoreInformation {String stunumber;String name;double mathematicss ...

  7. Java常用测试工具

    第一部分:九款性能测试 Java入门 如果你才刚开始接触Java世界,那么要做的第一件事情是,安装JDK——Java Development Kit(Java开发工具包),它自带有Java Runti ...

  8. 第一次java程序测试感受

    第一次JAVA程序设计测试,检验了一个暑假的成果.显而易见,我做的并不是很好,程序最起码的输入输出以及方法的定义还是没有问题的,但是考到了文件输入输出便看出来了.对于文件的输入输出,虽然我预习到那里, ...

  9. Java Junit测试框架

    Java    Junit测试框架 1.相关概念 Ø JUnit:是一个开发源代码的Java测试框架,用于编写和运行可重复的测试.它是用于单元测试框架体系xUnit的一个实例(用于java语言).主要 ...

随机推荐

  1. [20181225]12CR2 SQL Plan Directives.txt

    [20181225]12CR2 SQL Plan Directives.txt --//12C引入SQL PLAN Directives.12cR1版本会造成大量的动态取样,影响性能.许多人把OPTI ...

  2. C#面向对象 类

    ; i < ; i++) { student.b++;//静态字段若不赋值,默认为1: new student().a++;//引用类型变量定义后,必须使用new关键字创建对象 才能后才能使用 ...

  3. Powershell远程执行命令

    $Username = 'xx' $Password = 'xx' $ComputerName='xx' $pass = ConvertTo-SecureString -AsPlainText $Pa ...

  4. VMWare 虚拟机设置网络访问

    使用桥接模式 将本机IP设置为和虚拟机IP在同一个可以上网的网段中

  5. 谁记录了mysql error log中的超长信息

    [问题] 最近查看MySQL的error log文件时,发现有很多服务器的文件中有大量的如下日志,内容很长(大小在200K左右),从记录的内容看,并没有明显的异常信息. 有一台测试服务器也有类似的问题 ...

  6. UGUI组件之快速消息提示(飘字)

    效果预览 使用情景 几乎每一个游戏都会有这种飘字提示,实现起来并不复杂, 我把它做了一个组件. 开箱即可使用,无需二次开发,如果效果不满意,开放源码,方便进行调优. 组件源码 核心代码 每次将飘字的请 ...

  7. web测试笔记

    WEB兼容性测试 一.客户端兼容性 1.浏览器的兼容性测试 a.内核角度 Tridnt内核:代表作IE.腾讯.遨游.世界之窗等 Gecko内核:代表作Firefox webkit内核:代表作Safar ...

  8. java求解第N个素数(质数)

    面试中,遇到一个题目:求解第N个素数. import java.util.Scanner; public class GetPrimeNumber { public static int NthPri ...

  9. 【HNOI2016】最小公倍数

    [HNOI2016]最小公倍数 容易想到先将所有边按\(a\)排序,然后处理\(b\).(然后我就不会了 我们按\(a\)的权值分块,处理\(a\)权值位于第\(k\)个块的询问的时候,我们先将询问按 ...

  10. SpringMVC Controller 返回值几种类型

    SpringMVC Controller 返回值几种类型 2016年06月21日 19:31:14 为who而生 阅读数:4189 标签: Controller 返回值类型spring mvc 更多 ...