Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- using namespace std;
- void main()
- {
- int food, money, sum = 0;
- char again = 'y';
- while (again=='y'||again=='Y')
- {
- cout << "請問你要點甚麼餐?" << endl;
- cout << "1號餐200塊,2號餐300塊,3號餐150塊,4號餐50塊" << endl;
- cin >> food;
- switch (food)
- {
- case 1 :
- cout << "200元" << endl;
- sum += 200;
- cout << "目前總共" << sum << "元" << endl;
- break;
- case 2 :
- cout << "300元" << endl;
- sum += 300;
- cout << "目前總共" << sum << "元" << endl;
- break;
- case 3:
- cout << "150元" << endl;
- sum += 150;
- cout << "目前總共" << sum << "元" << endl;
- break;
- case 4:
- cout << "50元" << endl;
- sum += 50;
- cout << "目前總共" << sum << "元" << endl;
- break;
- default :
- cout << "不好意思沒有這份餐" << endl;
- }
- cout << "請問要繼續點餐嗎?" << endl;
- cin >> again;
- }
- cout << "這位客人總共是" << sum << "元,請付錢" << endl;
- cin >> money;
- if (money > sum)
- {
- cout << "找您" << money - sum << "元" << endl;
- }
- else
- cout << "您的錢不夠,請稍後備好錢再點餐" << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement