write a c++ program that will prompt the user to enter 10 names of students, 5 courses,…
- User
write a c++ program that will prompt the user to enter 10 names of students, 5 courses, course codes, marks and grade and should display names, course, course code, mark, grades
- Assistant
#include #include using namespace std;
int main() { string students[10]; string courses[5]; string courseCodes[5]; int marks[5]; char grades[5];
// Prompt the user to enter 10 names of students cout << "Enter the names of 10 students: " << endl; for (int i = 0; i < 10; i++) { getline(cin, students[i]); }
// Prompt the user to enter 5 courses cout << "Enter the names of 5 courses: " << endl; for (int i = 0; i < 5; i++) { getline(cin, courses[i]); }
// Prompt the user to enter the course codes cout << "Enter the course codes: " << endl; for (int i = 0; i < 5; i++) { getline(cin, courseCodes[i]); }
// Prompt the user to enter the marks for each course cout << "Enter the marks for each course: " << endl; for (int i = 0; i < 5; i++) { cout << "Enter the mark for " << courses[i] << ": "; cin >> marks[i]; }
// Calculate the grade for each course for (int i = 0; i < 5; i++) { if (marks[i] >= 80) { grades[i] = 'A'; } else if (marks[i] >= 70 && marks[i] < 80) { grades[i] = 'B'; } else if (marks[i] >= 60 && marks[i] < 70) { grades[i] = 'C'; } else if (marks[i] >= 50 && marks[i] < 60) { grades[i] = 'D'; } else { grades[i] = 'F'; } }