特色家政服务系统,最晚12月11日就要,麻烦大家了,有偿,急用 谢谢
6条回答 默认 最新
- ShowMeAI 2022-12-09 19:39关注
如下为完成的代码和运行结果,望采纳
#include <iostream> #include <string> #include <vector> using namespace std; // 定义顾客类,用来存储顾客的预约信息 class Customer { public: string name; // 姓名 string phone; // 电话 string address; // 住址 int area; // 住房面积 string start_time; // 开始工作时间 string clean_date; // 清扫日期 } ; // 定义家政公司类,用来管理家政服务 class CleaningCompany { public: // 预约登记 void register_customer(const Customer& customer) { customers.push_back(customer); } // 查询预约信息 void query_customer(const string& name) { for (const auto& customer : customers) { if (customer.name == name) { cout << "姓名: " << customer.name << endl; cout << "电话: " << customer.phone << endl; cout << "住址: " << customer.address << endl; cout << "住房面积: " << customer.area << endl; cout << "开始工作时间: " << customer.start_time << endl; cout << "清扫日期: " << customer.clean_date << endl; break; } } } // 计算清扫费用 int calculate_cost(const Customer& customer) { int cost = 300; // 清扫一次收费起点 300 元 if (customer.area > 80) { // 如果住房面积超过 80 平方米,则每增加 2 平方米,加收 10 元清洁费 cost += (customer.area - 80) / 2 * 10; } // 如果预约的开始工作时间在上午 11 点之后,每推退 1 小时,加收 10% 的补偿费 if (customer.start_time > "11:00") { // 计算两个时间之差,并将其转换为小时 int hours_diff = std::stoi(customer.start_time.substr(0, 2)) - 11; cost += hours_diff * 10 / 100; } return cost; } // 派工人员 vector<int> dispatch(const Customer& customer) { vector<int> workers; // 按照通路每广派工 5 人的原则,首先派 5 人 workers.push_back(5); // 如果住房面积超过 30 平方米,每增加 30 平方米,增加一名工人 if (customer.area > 30) { workers.push_back((customer.area - 30) / 30 + 1); } // 如果开始工作时间在 13:00 及之后,加派一人 if (customer.start_time >= "13:00") { workers.push_back(1); } // 如果开始工作时间在 15:00 及之后,加派两人 if (customer.start_time >= "15:00") { workers.push_back(2); } return workers; } private: vector<Customer> customers; // 顾客信息 } ; int main() { // 创建家政公司实例 CleaningCompany company; // 创建一个顾客实例 Customer customer; customer.name = "张三"; customer.phone = "12345678901"; customer.address = "北京市海淀区xx路xx号"; customer.area = 91; customer.start_time = "12:30"; customer.clean_date = "2022-12-09"; // 预约登记 company.register_customer(customer); // 查询预约信息 company.query_customer("张三"); // 计算清扫费用 cout << "清扫费用: " << company.calculate_cost(customer) << endl; // 派工人员 vector<int> workers = company.dispatch(customer); cout << "派工人数: "; for (int worker : workers) { cout << worker << " "; } cout << endl; return 0; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
- ¥15 下图接收小电路,谁知道原理
- ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
- ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
- ¥15 手机接入宽带网线,如何释放宽带全部速度
- ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
- ¥15 ETLCloud 处理json多层级问题
- ¥15 matlab中使用gurobi时报错
- ¥15 这个主板怎么能扩出一两个sata口
- ¥15 不是,这到底错哪儿了😭