特色家政服务系统,最晚12月11日就要,麻烦大家了,有偿,急用 谢谢
如下为完成的代码和运行结果,望采纳
#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;
}
看看先
C++特色家政服务管理系统
如有帮助望采纳
https://blog.csdn.net/qq_35960743/article/details/128201709
可以
为了方便题友和大家理解,将题目中题要简单提炼了下,如下是题目中关键的要素
1、收费:一次 300 标准< 房屋面积80平方 ; 超出 >80平方,每增加2平方多收 10 例:91平方,收费355
2、预约:2-7天
3、登记:姓名、电话、住址、住房面积、开始工作时间、清扫日期
4、订单时效:预约上午11点,最迟开始工作时间下午15点。推迟1H,补偿10%,开始工作时间以半小时为计量单位。例:78平,收费345。因为开始工作时间12:30,45元补偿费
5、派工:标准每户5人 面积每增加30平+1人;另外开始工作时间13:00后+1人、15:00后+2人
好难呀