当前位置:网站首页>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 ;
}
}
边栏推荐
- A summary of the 8544 problem that SolidWorks Standard cannot obtain a license
- 【QT】定时器
- JS string splicing
- Detailed comparison of Hynix emmc5.0 and 5.1 series
- 企业级日志分析系统ELK(如果事与愿违那一定另有安排)
- flink1.13 sql基础语法(二)join操作
- Public inputs in appliedzkp zkevm (13)
- TCP状态转换图
- 中科磐云—D模块解析以及评分标准
- Analysis of classical pointer and array written test questions in C language
猜你喜欢
补某视频网站的js,进行视频解密
[wechat applet] template and configuration (wxml, wxss, global and page configuration, network data request)
Flutter ‘/usr/lib/libswiftCore. dylib‘ (no such file)
Fault analysis | mongodb 5.0 reports an error, and the legal instruction solves it
Programming example of stm32f1 and stm32subeide -74hc595 drives 4-bit 7-segment nixie tube
Flutter calls Gaode map app to realize location search, route planning and reverse geocoding
2022 a special equipment related management (elevator) examination questions simulation examination platform operation
Trie number dictionary tree
LabVIEW错误对话框的出现
Notes on the paper "cross view transformers for real time map view semantic segmentation"
随机推荐
[matlab] matlab simulation modulation system FM system
Roles of rollup components
ping端口神器psping
Annex II: confidentiality agreement for offensive and defensive drills docx
力扣(LeetCode)184. 部门工资最高的员工(2022.07.03)
Notepad++ -- display related configurations
Useful plug-ins for vscode
远程桌面客户端 RDP
Get the ID of the record just inserted from laravel
[matlab] general function of communication signal modulation bandpass filter
[paper summary] zero shot semantic segmentation
Void convolution, deformable convolution, deformable ROI pooling
Error response from daemon: You cannot remove a running container 8d6f0d2850250627cd6c2acb2497002fc3
Evolution of system architecture: differences and connections between SOA and microservice architecture
June 2022 summary
中科磐云—2022广东木马信息获取解析
Etcd database source code analysis - initialization overview
Zhongke panyun-2022 Guangdong Trojan horse information acquisition and analysis
[matlab] matlab simulates digital baseband transmission system eye diagram of bipolar baseband signal (class I part response waveform)
小程序毕业设计---美食、菜谱小程序