特色家政服务系统,最晚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 winform的chart曲线生成时有凸起
- ¥15 msix packaging tool打包问题
- ¥15 finalshell节点的搭建代码和那个端口代码教程
- ¥15 Centos / PETSc / PETGEM
- ¥15 centos7.9 IPv6端口telnet和端口监控问题
- ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
- ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
- ¥20 海浪数据 南海地区海况数据,波浪数据
- ¥20 软件测试决策法疑问求解答