收银
import java.math.BigDecimal;
import java.util.Scanner;
public class 收銀系統方法 {
static Scanner scanner = new Scanner(System.in);
static double quantity;// 商品數量
static double price;// 商品單價
static double payment;// 用戶支付金額
static double change;// 找零
static double payable = 0;// 應付金額
static int Payment = 0;// 支付方式
static int strokeCount = 0;// 現金收銀筆數
static int strokeCount1 = 0;// 微信收銀筆數
static int strokeCount2 = 0;// 支付寶收銀筆數
static int strokeCount3 = 0;// 刷卡收銀筆數
static double toCollectMoney = 0;// 現金收銀金額;
static double toCollectMoney1 = 0;// 微信收銀筆數
static int toCollectMoney2 = 0;// 支付寶收銀筆數
static int toCollectMoney3 = 0;// 刷卡收銀筆數
static int number = 0;// 訂單總數
static double totalSum = 0;// 總額
static int inquire;// 選擇收銀或查詢
public static void main(String[] args) {
while (true) {
System.out.println(“歡迎使用天天收銀系統\n” + “請選擇你需要的業務\n” + “1.收銀 2.查看今日各支付筆數及收銀金額”);
inquire = scanner.nextInt();
if (inquire == 2) {
System.out.println(“歡迎使用查詢業務”);
pain();
}
System.out.println(“謝謝使用本系統”);
while (true) {
if(Payment6) {
return;
}
System.out.println(“歡迎使用收銀業務”);
System.out.println(“請輸入商品單價”);
price = scanner.nextDouble();
if (price == 0) {
break;
}
System.out.println(“請輸入商品數量”);
quantity = scanner.nextDouble();
System.out.println(“選擇支付方式:1.現金,2.微信,3.支付寶,4.刷卡”);
Payment = scanner.nextInt();
switch (Payment) {
case 1:
toCollectMoney += price * quantity;
strokeCount += 1;
publi(Payment, price, quantity);
break;
case 2:
toCollectMoney1 += price * quantity;
strokeCount1 += 1;
publi(Payment, price, quantity);
break;
case 3:
toCollectMoney2 += price * quantity;
strokeCount2 += 1;
publi(Payment, price, quantity);
break;
case 4:
toCollectMoney3 += price * quantity;
strokeCount3 += 1;
publi(Payment, price, quantity);
break;
default:
break;
}
}
}
}
public static void publi(int payme, double price1, double quantity1) {
payable = price1 * quantity1;
System.out.println(“應付金額” + payable);
System.out.println(“請輸入支付金額”);
payment = scanner.nextDouble();// 輸入金額
change = payment - payable;
BigDecimal b = new BigDecimal(change);
change = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
System.out.println(“支付金額:” + payment + “\n應付金額:” + payable + “\n找零金額” + change);
System.out.println(“感謝您的本次消費,祝您生活愉快!”);
}
public static void pain() {
while (true) {
System.out.println(“查看今日各支付筆數及金額\n1.現金,2.微信,3.支付寶,4.刷卡,5.營業總額”);
Payment = scanner.nextInt();
if(Payment6) {
return;
}
switch (Payment) {
case 1:
System.out.println(“現金支付筆數” + strokeCount + “金額為” + toCollectMoney);
break;
case 2:
System.out.println(“現金支付筆數” + strokeCount1 + “金額為” + toCollectMoney1);
break;
case 3:
System.out.println(“現金支付筆數” + strokeCount2 + “金額為” + toCollectMoney2);
break;
case 4:
System.out.println(“現金支付筆數” + strokeCount3 + “金額為” + toCollectMoney3);
break;
case 5:
number = strokeCount + strokeCount1 + strokeCount2 + strokeCount3;
totalSum = toCollectMoney + toCollectMoney1 + toCollectMoney2 + toCollectMoney3;
System.out.println(“總筆數” + number + “總金額為” + totalSum);
break;
default:
break;
}
}
}
}
總結
- 上一篇: 我的世界bukkit服务器开发教程第一章
- 下一篇: Gvim开发环境配置笔记--Window