update,
This commit is contained in:
7
_prompts/helloworld copy.md
Normal file
7
_prompts/helloworld copy.md
Normal file
@@ -0,0 +1,7 @@
|
||||
write some cpp functions:
|
||||
|
||||
This system collects student details like name, marks in each subject.
|
||||
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.
|
25
_prompts/helloworld.md
Normal file
25
_prompts/helloworld.md
Normal file
@@ -0,0 +1,25 @@
|
||||
write some cpp functions:
|
||||
|
||||
1. collects student details like name, marks in each subject.
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
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.
|
||||
add,
|
||||
edit and
|
||||
delete
|
||||
|
||||
|
||||
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.
|
41
_prompts/step1/step1.cpp
Normal file
41
_prompts/step1/step1.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
struct Student {
|
||||
std::string name;
|
||||
int maths_marks, chinese_marks, english_marks;
|
||||
char grade;
|
||||
};
|
||||
|
||||
int main() {
|
||||
while (true) {
|
||||
Student student;
|
||||
std::cout << "Enter name (or 'END' to quit): ";
|
||||
std::cin >> student.name;
|
||||
|
||||
if (student.name == "END") {
|
||||
break;
|
||||
}
|
||||
|
||||
std::cout << "Enter maths marks: ";
|
||||
std::cin >> student.maths_marks;
|
||||
|
||||
std::cout << "Enter chinese marks: ";
|
||||
std::cin >> student.chinese_marks;
|
||||
|
||||
std::cout << "Enter english marks: ";
|
||||
std::cin >> student.english_marks;
|
||||
|
||||
std::cout << "Enter grade: ";
|
||||
std::cin >> student.grade;
|
||||
|
||||
std::cout << "\nStudent details:\n";
|
||||
std::cout << "Name: " << student.name << "\n";
|
||||
std::cout << "Maths marks: " << student.maths_marks << "\n";
|
||||
std::cout << "Chinese marks: " << student.chinese_marks << "\n";
|
||||
std::cout << "English marks: " << student.english_marks << "\n";
|
||||
std::cout << "Grade: " << student.grade << "\n";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
17
_prompts/step1/step1.md
Normal file
17
_prompts/step1/step1.md
Normal file
@@ -0,0 +1,17 @@
|
||||
write a cpp function:
|
||||
|
||||
This system collects student details like name, marks in each subject.
|
||||
|
||||
using cpp, write a console program:
|
||||
that accepts user input
|
||||
- name,
|
||||
- maths marks,
|
||||
- chinese marks,
|
||||
- english marks and
|
||||
- grade,
|
||||
|
||||
loop until user enter "END" as name input
|
||||
print them out when the user input done
|
||||
|
||||
|
||||
|
40
_prompts/step2/prompt.md
Normal file
40
_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
_prompts/step2/test.cpp
Normal file
106
_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;
|
||||
}
|
16
_prompts/step3/prompt.md
Normal file
16
_prompts/step3/prompt.md
Normal file
@@ -0,0 +1,16 @@
|
||||
write some cpp functions:
|
||||
|
||||
- User can add, edit and delete the record to the system manually or upload a file.
|
||||
|
||||
using cpp, write a console program that accepts:
|
||||
user input a csv file path
|
||||
|
||||
the program then parse the inputted csv file and insert the record
|
||||
|
||||
```
|
||||
name,maths,chinese,english
|
||||
apple,99,98,99
|
||||
banana,99,98,99
|
||||
```
|
||||
|
||||
|
3
_prompts/step3/test.txt
Normal file
3
_prompts/step3/test.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
burger 15
|
||||
fries 11
|
||||
ice-cream 9
|
45
_prompts/step3/write_file.cpp
Normal file
45
_prompts/step3/write_file.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
//Declare variables
|
||||
ifstream inFile;
|
||||
ofstream outFile;
|
||||
string burger_name, fries_name, icecream_name;
|
||||
int burger_price, fries_price, icecream_price;
|
||||
//Open the input file and output file
|
||||
inFile.open("price.txt");
|
||||
|
||||
if (!inFile) {
|
||||
cout << "Cannot open the input file."
|
||||
<< "The program terminates." << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
outFile.open("price_output.out");
|
||||
cout << "Processing data" << endl;
|
||||
|
||||
//Read file word by word
|
||||
inFile >> burger_name >> burger_price;
|
||||
inFile >> fries_name >> fries_price;
|
||||
inFile >> icecream_name >> icecream_price;
|
||||
|
||||
//Output file
|
||||
outFile << "The price of " << burger_name
|
||||
<< " is $" << burger_price <<"." << endl;
|
||||
|
||||
outFile << "The price of " << fries_name
|
||||
<< " is $" << fries_price << "." << endl;
|
||||
|
||||
outFile << "The price of " << icecream_name
|
||||
<< " is $" << icecream_price << "." << endl;
|
||||
inFile.close(); // .close(): close a file
|
||||
outFile.close();
|
||||
cout << "Processing completed" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
13
_prompts/step4.md
Normal file
13
_prompts/step4.md
Normal file
@@ -0,0 +1,13 @@
|
||||
write some cpp functions:
|
||||
|
||||
This system collects student details like name, marks in each subject.
|
||||
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
|
||||
|
||||
|
||||
|
13
_prompts/step5.md
Normal file
13
_prompts/step5.md
Normal file
@@ -0,0 +1,13 @@
|
||||
write some cpp functions:
|
||||
|
||||
This system collects student details like name, marks in each subject.
|
||||
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
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user