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. [20190213]测试服务端打开那些端口.txt

    [20190213]测试服务端打开那些端口.txt --//前几天测试使用发送信息到/dev/tcp/ip_address/port,测试端口是否打开.写简单写一个脚本验证看看. $ seq 1 65 ...

  2. PHP实现邮件的自动发送

    最近做一个邮箱验证的功能,研究了一会,搞定了邮件的自动发送.下面用qq邮箱作为演示,一步一步来解释: 代码下载地址 首先,就是做到邮件的发送,代码如下: <?php//邮件发送require ' ...

  3. ShellExecuteEX打开iqy文件导致excel hang的原因分析

    1. 问题 当在console中调用API ShellExecuteEx打开"test.iqy"文件时,发现excel会hang住,console退出后excel才会响应,但直接双 ...

  4. LeetCode算法题-Contains Duplicate(Java实现)

    这是悦乐书的第192次更新,第196篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第52题(顺位题号是217).给定一个整数数组,查找数组是否包含任何重复项.如果数组中至 ...

  5. Servlet(一):Hello Servlet

    今天介绍的专题是servlet和jsp,属于web开发中的基础,先来实际操作一下servlet,创建你的第一个web小项目. 1.新建一个maven项目. 鼠标右键单击eclipse左边项目栏的空白区 ...

  6. mysql统计一年12月的数据

    效果图: select end) as 一月份, end) as 二月份, end) as 三月份, end) as 四月份, end) as 五月份, end) as 六月份, end) as 七月 ...

  7. 聚类——WKFCM

    聚类——认识WKFCM算法 作者:凯鲁嘎吉 - 博客园 http://www.cnblogs.com/kailugaji/ 参考文献:Shen H, Yang J, Wang S, et al. At ...

  8. 【项目 · Wonderland】立项报告

    [软件工程实践 · 团队项目] 第二次作业 团 队 作 业 原 文:http://www.cnblogs.com/andwho/p/7598662.html Part 0 · 简 要 目 录 Part ...

  9. 【Linux基础】Linux更改系统IP

    1.SUSE系统 (1)设置IP cd /etc/sysconfig/network/ vi ifcfg-eth0 BOOTPROTO='static'   #静态IPBROADCAST='192.1 ...

  10. (转)Spring Boot 2 (九):【重磅】Spring Boot 2.1.0 权威发布

    http://www.ityouknow.com/springboot/2018/11/03/spring-boot-2.1.html 如果这两天登录 https://start.spring.io/ ...