当前位置:网站首页>Easy change
Easy change
2022-07-04 05:19:00 【fanlangke】
source : oracle Zero basis 30 Heaven Society Java
SmallChangeSysAPP
package com.hspedu.smallchange.oop;
import com.hspedu.smallchange.SmallChangeSys;
public class SmallChangeSysAPP {
public static void main(String[] args) {
new SmallChangeSysOOP().mainMenu();
}
}
SmallChangeSysOOP
package com.hspedu.smallchange.oop;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
public class SmallChangeSysOOP {
boolean loop = true;
Scanner scanner = new Scanner(System.in);
String key = "";
String details = "---------- Change details ----------";
double money = 0;
double balance = 0;
Date date = null;
String note = null;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
public void mainMenu() {
do {
System.out.println("========== Zero money ==========");
System.out.println("\t\t\t1 Change details ");
System.out.println("\t\t\t2 Income entry ");
System.out.println("\t\t\t3 consumption ");
System.out.println("\t\t\t4 sign out ");
System.out.println(" Please select (1-4):");
this.key = this.scanner.next();
switch (this.key) {
case "1":
this.detail();
break;
case "2":
this.income();
break;
case "3":
this.pay();
break;
case "4":
this.exit();
break;
default:
System.out.println(" Wrong choice , Please reselect ");
}
}while(loop);
System.out.println("----- Quit the change project -----");
}
public void detail(){
System.out.println(details);
}
public void income(){
System.out.println(" The recorded amount of income :");
money=scanner.nextDouble();
if(money<0){
System.out.println(" Income entry amount cannot be less than 0");
return;
}
balance+=money;
date =new Date();
details+="\n Income entry \t+"+money+"\t"+sdf.format(date);
}
public void pay(){
System.out.println(" Consumption amount :");
money=scanner.nextDouble();
if(money<0||money>balance){
System.out.println(" Income entry amount cannot be less than 0");
return;
}
System.out.println(" Consumption description :");
note=scanner.next();
balance-=money;
date =new Date();
details+="\n"+note+"\t-"+money+"\t"+sdf.format(date);
}
public void exit(){
String choice="";
while(true){
System.out.println(" Are you sure you want to quit ?y/n");
choice=scanner.next();
if(choice.equals("y")||choice.equals("n")){
break;
}
}
if(choice.equals("n")){
return ;
}
loop=false;
return ;
}
}
边栏推荐
- 【兴趣阅读】Adversarial Filtering Modeling on Long-term User Behavior Sequences for Click-Through Rate Pre
- 2022年R2移动式压力容器充装复训题库及答案
- COMP1721 Creating Classes
- 2022g2 power station boiler stoker special operation certificate examination question bank and answers
- 空洞卷积、可变形卷积、可变形ROI Pooling
- [technology development -25]: integration technology of radio and television network, Internet, telecommunication network and power grid
- KMP match string
- Zhongke panyun-2022 Guangdong Trojan horse information acquisition and analysis
- Capturing and sorting out external Fiddler -- Conversation bar and filter
- VB.net GIF(制作、拆解——优化代码,类库——5)
猜你喜欢

2022年R2移动式压力容器充装复训题库及答案

KMP匹配字符串

Void convolution, deformable convolution, deformable ROI pooling

Unity is connected to the weather system

Etcd database source code analysis - initialization overview
![[paper summary] zero shot semantic segmentation](/img/78/ee64118d86a7e43ec4d1cb97191fbe.jpg)
[paper summary] zero shot semantic segmentation

c语言经典指针和数组笔试题解析
![[interested reading] advantageous filtering modeling on long term user behavior sequences for click through rate pre](/img/3e/b5df691ca1790469eb1b4e8ea5b4c0.png)
[interested reading] advantageous filtering modeling on long term user behavior sequences for click through rate pre

令人头痛的延时双删

Simulated small root pile
随机推荐
VB.net 调用FFmpeg简单处理视频(类库——6)
Download kicad on Alibaba cloud image station
令人头痛的延时双删
Simulink and Arduino serial port communication
How to use postman to realize simple interface Association [add, delete, modify and query]
2022 a special equipment related management (elevator) examination questions simulation examination platform operation
模拟小根堆
2022 R2 mobile pressure vessel filling retraining question bank and answers
laravel 中获取刚刚插入的记录的id
Flink1.13 SQL basic syntax (I) DDL, DML
Evolution of system architecture: differences and connections between SOA and microservice architecture
Annex II: confidentiality agreement for offensive and defensive drills docx
Detailed comparison of Hynix emmc5.0 and 5.1 series
空洞卷积、可变形卷积、可变形ROI Pooling
Notepad++ -- display related configurations
[technology development -25]: integration technology of radio and television network, Internet, telecommunication network and power grid
Fault analysis | mongodb 5.0 reports an error, and the legal instruction solves it
Public inputs in appliedzkp zkevm (13)
Etcd database source code analysis - initialization overview
Headache delayed double deletion