C++汽车租赁系统

信息包括:租赁人姓名、所租赁的汽车的品牌、所租赁的汽车的型号、汽车出厂时间、租赁定金、总费用。

(2)系统的主要功能如下:

1、汽车租赁信息的录入。

2、汽车租赁信息的查询。

3、汽车租赁信息的修改。

4、汽车租赁信息的删除。

5、显示汽车租赁信息。

废话少说直接上源码: 

#include <iostream>
#include <string>
using namespace std;
struct carinformation
{
	string factory;
	string brand;
	string moder;
	string Ftime;
	string customer;
	string fmoney;
	string tmoney;
};
struct carmenber
{
	carinformation array[1000];
	int size;
};
void addcarinformation(carmenber  *p)
{ if(p->size==1000)
{cout<<"次管理系统已满,无法继续添加租赁信息";}
else
	{cout<<"请输入租赁人姓名"<<endl;
	string name;
	cin>>name;
	p->array[p->size].customer=name;
	cout<<"请输入所租赁汽车的品牌"<<endl;
	string bran;
	cin>>bran;
	p->array[p->size].brand=bran;
	cout<<"请输入汽车的生产厂家"<<endl;
	string factor;
	cin>>factor;
	p->array[p->size].factory=factor;
	cout<<"请输入汽车出厂时间(-年-月-日)"<<endl;
	string time1;
	cin>>time1;
	p->array[p->size].Ftime=time1;
	cout<<"请输入汽车的租赁定金(元)"<<endl;
	string money1;
	cin>>money1;
	p->array[p->size].fmoney=money1;
	cout<<"请输入汽车租赁总费用(元)"<<endl;
	string money2;
	cin>>money2;
	p->array[p->size].tmoney=money2;
	cout<<"录入信息成功!"<<endl;
	p->size++;
	cout<<"请按回车键清屏!"<<endl;}
	system ("pause");
	system("cls");
}
void inqure(carmenber *p)
{  
	if(p->size==0)
	{cout<<"当前数据为空!";
	}
	else
	{
		int j;
	for(j=0;j<p->size;j++)
		{cout<<"租赁人姓名:"<<" "<<p->array[j].customer<<"   ";
		cout<<"所租赁汽车的品牌:"<<" "<<p->array[j].brand<<"   ";
		cout<<"生产厂家:"<<" "<<p->array[j].factory<<"  ";
		cout<<"出厂时间:"<<p->array[j].Ftime<<"  ";
		cout<<"租赁定金:"<<" "<<p->array[j].fmoney<<"元"<<"  ";
		cout<<"租用总费用:"<<" "<<p->array[j].tmoney<<"元"<<"  ";
		cout<<endl;}
	
	}

	system ("pause");
	system("cls");
}
void find(carmenber *p)
{string named;

cout<<"请输入需查询的租赁人姓名"<<endl;
	cin>>named;
	int t;
	for(t=0;t<p->size;t++)
	if(named==p->array[t].customer)
       {cout<<"租赁人姓名:"<<" "<<p->array[t].customer<<"   ";
		cout<<"所租赁汽车的品牌:"<<" "<<p->array[t].brand<<"   ";
		cout<<"所租汽车型号为:"<<p->array[t].moder<<"   ";
		cout<<"生产厂家:"<<" "<<p->array[t].factory<<"  ";
		cout<<"出厂时间:"<<p->array[t].Ftime<<"  ";
		cout<<"租赁定金:"<<" "<<p->array[t].fmoney<<"元"<<"  ";
		cout<<"租用总费用:"<<" "<<p->array[t].tmoney<<"元"<<endl;
	}
	else
{	cout<<"查无此人!"<<endl;} 
	cout<<"请按回车键清屏!"<<endl;
	system ("pause");
	system("cls");
}
void modify(carmenber *p)
{
	cout<<"请输入所要修改的租赁人的姓名"<<endl;
	string name;
	cin>>name;
	int h;
	for(h=0;h<p->size;h++)
	{
		if(name==p->array[h].customer)
		{cout<<"(0)租赁人(1)汽车品牌(2)生产厂家(3)出厂时间(4)租赁定金(5)租赁总费用 (6)全部修改 (7)汽车型号"<<endl<<endl;;
		cout<<"请输入相应的数字所对应的修改信息选项"<<endl;
		int z;
		cin>>z;
		string str;
		if(z==0)
		{cout<<"请输入输入所修改的租赁人姓名"<<endl;
		cin>>str;
		p->array[h].customer=str;
		cout<<"修改成功!"<<endl;
		}
		if(z==1)
		{cout<<"请输入所修改的汽车品牌"<<endl;
		cin>>str;
		p->array[h].brand=str;
		cout<<"修改成功!"<<endl;
		}
		if(z==2)
		{
		cout<<"请输入您所要修改的汽车生产厂家"<<endl;
		cin>>str;
		p->array[h].factory=str;
		cout<<"修改成功!"<<endl;
		}
		if(z==3)
		{
			cout<<"请输入您所要修改的汽车出厂时间"<<endl;
			cin>>str;
			p->array[h].Ftime=str;
		cout<<"修改成功!"<<endl;
		}
		if(z==4)
		{
			int x;
		cout<<"请输入您所要修改的汽车租赁定金"<<endl;
		cin>>x;
		p->array[h].fmoney=x;
		cout<<"修改成功!"<<endl;
		}
		if(z==5)
		{int y;
		cout<<"请输入您所修改的汽车租赁总费用"<<endl;
		cin>>y;
		p->array[h].tmoney=y;
		cout<<"修改成功!"<<endl;
		}
		if(z==6)
		{string a,b,c;
		cout<<"请输入您修改的租赁人姓名"<<endl;
		cin>>str;
		p->array[h].customer=str;
		cout<<"请输入您修改的汽车品牌"<<endl;
		cin>>str;
		p->array[h].brand=str;
		cout<<"请输入您所要修改的汽车生产厂家"<<endl;
		cin>>str;
		p->array[h].factory=str;
		cout<<"请输入您所修改的汽车出厂时间"<<endl;
		cin>>str;
		p->array[h].Ftime=str;
		cout<<"请输入您所修改的汽车租赁定金"<<endl;
		cin>>a;
		p->array[h].fmoney=a;
		cout<<"请您输入您所修改的汽车租赁总费用"<<endl;
		cin>>b;
		p->array[h].tmoney=b;
		cout<<"请您输入您所修改的汽车型号"<<endl;
		cin>>c;
		p->array[h].moder=c;
		cout<<"信息修改成功!"<<endl;
		}
		if(z==7)
		{string k;
			cout<<"请您输入您所修改的汽车型号"<<endl;
		cin>>k;
		p->array[h].moder=k;
		cout<<"信息修改成功!"<<endl;
		}
		
		break;
		}
		
	
	}

	system ("pause");
	 system("cls");
}


	 

void delet(carmenber *p)
{
	int j,i;
	cout<<"请输入需删除汽车租赁信息数据的租赁人姓名"<<endl;
	string str1;
	cin>>str1;
for(i=0;i<p->size;i++)
{
	if(str1==p->array[i].customer)
	{
		for(j=i;j<p->size;j++)
		{
			p->array[j]=p->array[j+1];
		}
		p->size--;
		cout<<"该租赁人信息已删除!"<<endl;
		break;
	}
	else
	{cout<<"未查到此人!"<<endl;
	break;
	}
	}
	system ("pause");
	 system("cls");


 } 
void showmenu()
{
	cout<<"                                    ****欢迎使用pioneer汽车租赁信息管理系统****"<<endl<<endl;
	cout<<"                                          |<汽车租赁信息管理系统菜单>|"<<endl; 
	cout<<"                                   "<<" |<<<<<<<<<"<<"1汽车租赁信息数据的录入"<<">>>>>>>|"<<endl;
	cout<<"                                   "<<" | <<<<<<<"<<"2汽车租赁信息数据的查询"<<">>>>>>  |"<<endl;
	cout<<"                                   "<<" |   <<<<<"<<" 3汽车租赁信息数据的修改"<<">>>>>  |"<<endl;
	cout<<"                                   "<<" |     <<<<"<<"4汽车租赁信息数据的删除"<<">>>>   |"<<endl;
	cout<<"                                   "<<" |       <<<"<<"5显示全部汽车租赁信息"<<">>>     |"<<endl;
	cout<<"                                   "<<" -----------------------------------------"<<endl; 
}
int main()
{
	int i=0;
	carmenber user;
	user.size=0;
	while(true)
	{showmenu();
	 cout<<"请输入数字以便执行相应的操作!"<<endl;
	 cin>>i;
	 switch(i)
	{
	  {case 1:
	  addcarinformation(&user);
	  break;
	}
	  case 2:
		 { find(&user);
		  break;}
	  case 3:
        {modify(&user);
		 break;}
	  case 4:
	   	{
	   		delet(&user);
	   		break;
		   }
	  case 5:
	  {inqure(&user);
	   break;}
	  	default:  
			{cout<<"抱歉没有此数字对应的功能,请按回车键后重新输入!"<<endl;
				system ("pause");
	            system("cls");
				break;}
	}
	}
	system("pause");
	return 0;
}

  • 6
    点赞
  • 42
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论
一个简单的汽车租赁管理系统C++控制台程序): 利用C++实现对汽车和客户信息的增、删、改等操作,并保存。 部分代码: // CarRent.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include "CarData.h" #include "Menu.h" #include"CustomerData.h" int main() { Menu::welcome(); Menu::login(); //登录界面 char choice; int carid, customerid; //汽车编号,客户编号 CustomerData CustomerDB; //客户库 Customer *r; //客户 CarData CarDB; //汽车库 Car *b; //汽车 Menu::showMenu(); //显示菜单 cout <> choice; while (choice != '0') { switch (choice) { case '1': //输入客户编号和要出租的汽车 cout <> customerid; try { if (customerid <= 0) throw 1; } catch (...) { cout << "输入有误,请重新输入"; break; } cout <> carid; try { if (carid <= 0) throw 1; } catch (...) { cout << "输入有误,请重新输入"; break; } r = CustomerDB.search(customerid); if (NULL == r) { cout << "不存在该客户!"; cout << endl; break; } b = CarDB.search(carid); if (b == NULL) { cout << "不存在该汽车!"; cout <borrowCar() == 0) { cout << "该汽车已租出!"; cout <borrowCar(b->getNo()); cout << "你在" <getBorTime()) << "成功出租一辆" <getName() << endl << "每日租金为(不足一天按一天计算):" <getPay(); break; case '2': //归还操作 cout <> customerid; try { if (customerid <= 0) throw 1; } catch (...) { cout << "输入有误,请重新输入"; break; } cout <> carid; try { if (carid <= 0) throw 1; } catch (...) { cout << "输入有误,请重新输入"; break; } r = CustomerDB.search(customerid); //按编号查找 if (r == NULL) { cout << "不存在该客户!" << endl; break; } b = CarDB.search(carid); if (b == NULL) { cout << "不存在该汽车!" <getOnshelf() == 1) { cout << "该汽车已经归还!" << endl; break; } cout << "您成功归还一辆"
好的,下面是一个简单的汽车租赁系统的示例代码,仅供参考: ```c++ #include <iostream> #include <string> #include <vector> using namespace std; class Car { public: string brand; string model; int year; double price; bool available; Car(string b, string m, int y, double p, bool a) { brand = b; model = m; year = y; price = p; available = a; } }; class Rental { public: string renter_name; Car car; int rental_days; Rental(string rn, Car c, int rd) { renter_name = rn; car = c; rental_days = rd; } double get_total_price() { return rental_days * car.price; } }; int main() { vector<Car> cars; cars.push_back(Car("Toyota", "Camry", 2015, 50.0, true)); cars.push_back(Car("Honda", "Accord", 2018, 70.0, true)); cars.push_back(Car("Ford", "Mustang", 2020, 120.0, true)); vector<Rental> rentals; while (true) { cout << "1. Rent a car" << endl; cout << "2. Return a car" << endl; cout << "3. Exit" << endl; cout << "Enter your choice: "; int choice; cin >> choice; if (choice == 1) { cout << "Available cars:" << endl; for (int i = 0; i < cars.size(); i++) { if (cars[i].available) { cout << i << ". " << cars[i].brand << " " << cars[i].model << " (" << cars[i].year << ") - $" << cars[i].price << "/day" << endl; } } int car_choice; cout << "Enter car choice: "; cin >> car_choice; if (cars[car_choice].available) { string renter_name; cout << "Enter renter name: "; cin >> renter_name; int rental_days; cout << "Enter rental days: "; cin >> rental_days; cars[car_choice].available = false; rentals.push_back(Rental(renter_name, cars[car_choice], rental_days)); cout << "Successfully rented " << cars[car_choice].brand << " " << cars[car_choice].model << " to " << renter_name << "." << endl; } else { cout << "Car is not available." << endl; } } else if (choice == 2) { cout << "Rented cars:" << endl; for (int i = 0; i < rentals.size(); i++) { cout << i << ". " << rentals[i].car.brand << " " << rentals[i].car.model << " (" << rentals[i].car.year << ") - $" << rentals[i].car.price << "/day - Rented to " << rentals[i].renter_name << " for " << rentals[i].rental_days << " days." << endl; } int rental_choice; cout << "Enter rental choice: "; cin >> rental_choice; if (rental_choice < rentals.size()) { double total_price = rentals[rental_choice].get_total_price(); cout << "Total price for " << rentals[rental_choice].rental_days << " days is $" << total_price << "." << endl; cars.push_back(rentals[rental_choice].car); cars.back().available = true; rentals.erase(rentals.begin() + rental_choice); cout << "Successfully returned " << cars.back().brand << " " << cars.back().model << "." << endl; } else { cout << "Invalid rental choice." << endl; } } else if (choice == 3) { break; } else { cout << "Invalid choice." << endl; } } return 0; } ``` 这个系统使用了两个类:`Car` 和 `Rental`,分别表示汽车和租赁情况。主函数中创建了一个汽车列表和一个租赁列表,然后进入一个循环,让用户进行操作。 用户可以选择租用汽车或归还汽车,当租用汽车时,系统会列出当前可用的汽车列表,并要求用户输入租用的汽车、租用天数和租用人的姓名。当归还汽车时,系统会列出当前已租用的汽车列表,并要求用户输入要归还的租赁记录。系统会计算出租赁总价,并将汽车标记为可用状态,从租赁列表中删除相应的记录。 这只是一个简单的示例代码,实际的汽车租赁系统可能需要更复杂的功能和更完善的界面设计。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

James Buchanan

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值