当前位置:网站首页>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 ;
}
}
边栏推荐
- With the advent of the IP era, how can E-sports hotels take advantage of the "east wind" of games?
- ETCD数据库源码分析——初始化总览
- [matlab] communication signal modulation general function interpolation function
- Analysis of classical pointer and array written test questions in C language
- 《Cross-view Transformers for real-time Map-view Semantic Segmentation》论文笔记
- Thread pool: use thread pool to optimize query speed
- Remote desktop client RDP
- [技术发展-25]:广播电视网、互联网、电信网、电网四网融合技术
- 2022危险化学品经营单位安全管理人员上岗证题库及答案
- [matlab] communication signal modulation general function - low pass filter
猜你喜欢

Zhongke panyun-d module analysis and scoring standard

KMP match string

Flutter calls Gaode map app to realize location search, route planning and reverse geocoding
![[high concurrency, high performance and high availability of massive data MySQL practice-7] - memory data drop disk](/img/b9/cf4db4f8a5d2ef3fb344258f0e30f5.jpg)
[high concurrency, high performance and high availability of massive data MySQL practice-7] - memory data drop disk

Flutter ‘/usr/lib/libswiftCore. dylib‘ (no such file)

Programming example of stm32f1 and stm32subeide -74hc595 drives 4-bit 7-segment nixie tube

中職組網絡安全—內存取證

【QT】定时器

Write a complete answer applet (including single choice questions, judgment questions and multiple topics) (III) single choice questions, judgment questions, and the first question display
![[技术发展-25]:广播电视网、互联网、电信网、电网四网融合技术](/img/87/e0469e280365ed0261e2b551ebd888.png)
[技术发展-25]:广播电视网、互联网、电信网、电网四网融合技术
随机推荐
Using jsts in esmodule environment
2022G2电站锅炉司炉特种作业证考试题库及答案
远程桌面客户端 RDP
Rollup各组件作用
Just do it with your hands 7 - * project construction details 2 - hook configuration
Flutter ‘/usr/lib/libswiftCore. dylib‘ (no such file)
Nodejs learning document
Secondary vocational group network security - memory Forensics
Daily question brushing record (12)
Unity2d -- character moves and turns
Simulated small root pile
Detailed comparison of Hynix emmc5.0 and 5.1 series
由于使用flash存放参数时,擦除掉了flash的代码区导致进入硬件错误中断
With the advent of the IP era, how can E-sports hotels take advantage of the "east wind" of games?
2022年A特种设备相关管理(电梯)考试题模拟考试平台操作
中科磐云—模块A 基础设施设置与安全加固 评分标准
Annex 2-2 confidentiality commitment docx
2022危险化学品经营单位安全管理人员上岗证题库及答案
[matlab] matlab simulation of modulation system - power spectrum and coherent demodulation of AM modulated signal
Void convolution, deformable convolution, deformable ROI pooling