update,
This commit is contained in:
40
marissa.sam/_prompts/step2/prompt.md
Normal file
40
marissa.sam/_prompts/step2/prompt.md
Normal file
@@ -0,0 +1,40 @@
|
||||
write some cpp functions:
|
||||
|
||||
```
|
||||
Add marks record
|
||||
Delete marks record
|
||||
Edit marks record
|
||||
Print current marks record in system
|
||||
|
||||
press E to exit
|
||||
```
|
||||
|
||||
if the user entered 1, the run `functionAdd` so on and forth
|
||||
|
||||
```cpp
|
||||
#include <iostream>
|
||||
|
||||
void print_menu() {
|
||||
std::cout << "Mark Record System\n";
|
||||
std::cout << "-----------------\n";
|
||||
std::cout << "1. Add marks record\n";
|
||||
std::cout << "2. Delete marks record\n";
|
||||
std::cout << "3. Edit marks record\n";
|
||||
std::cout << "4. Print current marks record in system\n";
|
||||
std::cout << "E. Exit\n";
|
||||
std::cout << "Enter your choice: ";
|
||||
}
|
||||
```
|
||||
|
||||
write a cpp function that print the above menu
|
||||
|
||||
The system can calculates the overall grade of each student.
|
||||
User can add, edit and delete the record to the system manually or upload a file.
|
||||
The system should have a counter to check how many records are update on each time.
|
||||
User can generate report and the report should be able to download.
|
||||
|
||||
using cpp, write a console program that accepts user input name, maths marks, chinese marks, english marks and grade,
|
||||
print them out when the user input done
|
||||
|
||||
|
||||
|
106
marissa.sam/_prompts/step2/test.cpp
Normal file
106
marissa.sam/_prompts/step2/test.cpp
Normal file
@@ -0,0 +1,106 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
struct MarksRecord {
|
||||
std::string name;
|
||||
int maths_marks, chinese_marks, english_marks;
|
||||
};
|
||||
|
||||
std::vector<MarksRecord> records;
|
||||
|
||||
void print_menu() {
|
||||
std::cout << "Mark Record System\n";
|
||||
std::cout << "-----------------\n";
|
||||
std::cout << "1. Add marks record\n";
|
||||
std::cout << "2. Delete marks record\n";
|
||||
std::cout << "3. Edit marks record\n";
|
||||
std::cout << "4. Print current marks record in system\n";
|
||||
std::cout << "E. Exit\n";
|
||||
std::cout << "Enter your choice: ";
|
||||
}
|
||||
|
||||
void functionAdd() {
|
||||
MarksRecord record;
|
||||
std::cout << "Enter name: ";
|
||||
std::cin >> record.name;
|
||||
std::cout << "Enter maths marks: ";
|
||||
std::cin >> record.maths_marks;
|
||||
std::cout << "Enter chinese marks: ";
|
||||
std::cin >> record.chinese_marks;
|
||||
std::cout << "Enter english marks: ";
|
||||
std::cin >> record.english_marks;
|
||||
records.push_back(record);
|
||||
}
|
||||
|
||||
void functionDelete() {
|
||||
std::string name;
|
||||
std::cout << "Enter name to delete: ";
|
||||
std::cin >> name;
|
||||
for (size_t i = 0; i < records.size(); i++) {
|
||||
if (records[i].name == name) {
|
||||
records.erase(records.begin() + i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void functionEdit() {
|
||||
std::string name;
|
||||
std::cout << "Enter name to edit: ";
|
||||
std::cin >> name;
|
||||
for (size_t i = 0; i < records.size(); i++) {
|
||||
if (records[i].name == name) {
|
||||
std::cout << "Enter new maths marks: ";
|
||||
std::cin >> records[i].maths_marks;
|
||||
std::cout << "Enter new chinese marks: ";
|
||||
std::cin >> records[i].chinese_marks;
|
||||
std::cout << "Enter new english marks: ";
|
||||
std::cin >> records[i].english_marks;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void functionPrint() {
|
||||
for (const auto& record : records) {
|
||||
std::cout << "Name Maths Chinese English Grade " << "\n";
|
||||
std::cout << record.name << " "
|
||||
<< record.maths_marks << " "
|
||||
<< record.chinese_marks << " "
|
||||
<< record.english_marks << " "
|
||||
<< "\n";
|
||||
std::cout << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
char choice;
|
||||
while (true) {
|
||||
print_menu();
|
||||
std::cin >> choice;
|
||||
|
||||
switch (choice) {
|
||||
case '1':
|
||||
functionAdd();
|
||||
break;
|
||||
case '2':
|
||||
functionDelete();
|
||||
break;
|
||||
case '3':
|
||||
functionEdit();
|
||||
break;
|
||||
case '4':
|
||||
functionPrint();
|
||||
break;
|
||||
case 'E':
|
||||
case 'e':
|
||||
return 0;
|
||||
default:
|
||||
std::cout << "Invalid choice. Please try again.\n";
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user