写一个C++语言的教材管理系统 内容要求: 系统主要包括了教材订购、教材出售、教材统计、库存管理几大部分,其中功能主要包括:一、教材订购(1.订购信息登记 2.订购信息查询)二、教材出售(1.出售录入 2.销售信息查询)三、教材统计(1.每日统计 2.按库位号统计 3.销售统计)四、库存管理(1.库存信息 2.库存预警)。
时间: 2024-04-09 15:32:01 浏览: 8
好的,下面是一个简单的C++语言的教材管理系统的代码示例:
```cpp
#include <iostream>
#include <string>
#include <vector>
using namespace std;
struct Textbook {
string title;
string author;
int quantity;
};
class TextbookManagementSystem {
private:
vector<Textbook> textbooks;
public:
void orderTextbook() {
Textbook textbook;
cout << "Enter textbook title: ";
cin >> textbook.title;
cout << "Enter textbook author: ";
cin >> textbook.author;
cout << "Enter quantity: ";
cin >> textbook.quantity;
textbooks.push_back(textbook);
cout << "Textbook ordered successfully!" << endl;
}
void searchOrderInfo() {
string title;
cout << "Enter textbook title to search: ";
cin >> title;
for (const auto& textbook : textbooks) {
if (textbook.title == title) {
cout << "Textbook found!" << endl;
cout << "Title: " << textbook.title << endl;
cout << "Author: " << textbook.author << endl;
cout << "Quantity: " << textbook.quantity << endl;
return;
}
}
cout << "Textbook not found!" << endl;
}
void sellTextbook() {
string title;
cout << "Enter textbook title: ";
cin >> title;
for (auto& textbook : textbooks) {
if (textbook.title == title) {
int quantity;
cout << "Enter quantity to sell: ";
cin >> quantity;
if (quantity <= textbook.quantity) {
textbook.quantity -= quantity;
cout << "Textbook sold successfully!" << endl;
} else {
cout << "Insufficient quantity in stock!" << endl;
}
return;
}
}
cout << "Textbook not found!" << endl;
}
void searchSaleInfo() {
string title;
cout << "Enter textbook title to search: ";
cin >> title;
for (const auto& textbook : textbooks) {
if (textbook.title == title) {
cout << "Textbook found!" << endl;
cout << "Title: " << textbook.title << endl;
cout << "Author: " << textbook.author << endl;
cout << "Quantity: " << textbook.quantity << endl;
return;
}
}
cout << "Textbook not found!" << endl;
}
void dailyStatistics() {
int totalQuantity = 0;
for (const auto& textbook : textbooks) {
totalQuantity += textbook.quantity;
}
cout << "Total quantity of textbooks in stock: " << totalQuantity << endl;
}
void locationStatistics() {
string title;
cout << "Enter textbook title to search: ";
cin >> title;
int totalQuantity = 0;
for (const auto& textbook : textbooks) {
if (textbook.title == title) {
totalQuantity += textbook.quantity;
}
}
cout << "Total quantity of textbook \"" << title << "\" in stock: " << totalQuantity << endl;
}
void salesStatistics() {
int totalQuantitySold = 0;
for (const auto& textbook : textbooks) {
totalQuantitySold += (textbook.quantity - textbook.quantity);
}
cout << "Total quantity of textbooks sold: " << totalQuantitySold << endl;
}
void inventoryManagement() {
for (const auto& textbook : textbooks) {
cout << "Title: " << textbook.title << endl;
cout << "Author: " << textbook.author << endl;
cout << "Quantity: " << textbook.quantity << endl;
}
}
void inventoryWarning() {
for (const auto& textbook : textbooks) {
if (textbook.quantity <= 5) {
cout << "Inventory warning for textbook \"" << textbook.title << "\": Quantity is low (" << textbook.quantity << ")" << endl;
}
}
}
};
int main() {
TextbookManagementSystem system;
int choice;
do {
cout << "========== Textbook Management System ==========" << endl;
cout << "1. Order Textbook" << endl;
cout << "2. Search Order Information" << endl;
cout << "3. Sell Textbook" << endl;
cout << "4. Search Sale Information" << endl;
cout << "5. Daily Statistics" << endl;
cout << "6. Location Statistics" << endl;
cout << "7. Sales Statistics" << endl;
cout << "8. Inventory Management" << endl;
cout << "9. Inventory Warning" << endl;
cout << "0. Exit" << endl;
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1:
system.orderTextbook();
break;
case 2:
system.searchOrderInfo();
break;
case 3:
system.sellTextbook();
break;
case 4:
system.searchSaleInfo();
break;
case 5:
system.dailyStatistics();
break;
case 6:
system.locationStatistics();
break;
case 7:
system.salesStatistics();
break;
case 8:
system.inventoryManagement();
break;
case 9:
system.inventoryWarning();
break;
case 0:
cout << "Exiting..." << endl;
break;
default:
cout << "Invalid choice! Please try again." << endl;
break;
}
cout << endl;
} while (choice != 0);
return 0;
}
```
这个教材管理系统包含了教材订购、教材出售、教材统计和库存管理等功能,你可以根据需要进行修改和扩展。希望能对你有所帮助!