حاولت حل المسألة بهذه الشيفرة
#include<iostream>
# include<string.h>
using namespace std;
int main() {
string name, education_level;
int i, n = 0, p = 0, pr = 0, se = 0;
for (i = 0; i < 4; i++) {
cout << "Enter name: ";
cin >> name; // user name
cout << "Enter education level: ";
cin >> education_level; // user education level
if (education_level == "Nursery") {
n += 1;
}
else if (education_level == "Primary") {
p += 1;
}
else if (education_level == "Preparatory") {
pr += 1;
}
else if (education_level == "Secondary") {
se += 1;
}
}
float cost;
if (n == 1 && p == 2) {
cost = 10000 + (2 * 15000);
cost = cost - ((15 * cost) / 100);
}
else if (p == 1 && se == 1) {
cost = 15000 + 22000;
cost = cost - ((10 * cost) / 100);
}
else if (n == 1 && pr == 2) {
// three brothers Nursery && 2 Preparatory
cost = 10000 + (2 * 20000);
cost = cost - ((15 * cost) / 100);
}
else {
cost = 10000 + 15000 + 20000 + 22000;
}
cout << "Cost: " << cost << endl;
return 0;
}