Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

C++ Assignment on Search and Sort for Chapter 8 Problem: Modify the student grade problem to include the following: Write a Search function to search

C++ Assignment on Search and Sort for Chapter 8 Problem: Modify the student grade problem to include the following:

Write a Search function to search by student score Write a Search function to search by student last name Write a Sort function to sort the list by student score Write a Sort function to sort the list by student last name Write a menu function that lets user to choose any action he/she want to do.

Make sure your program has option to test the program as many times as the user wants.

Student Grade Problem below:

#include #include #include

using namespace std;

// Function to calculate grade char calcGrade(float n) { if (n>=9) return 'A'; if (n>=8 && n<9) return 'B'; if (n>=7 && n<8) return 'C'; if (n>=6 && n<7) return 'D'; else return 'F'; }

int main() { // A structure variable struct student { string name; float test1, test2, lab, quiz, final, total; char grade; };

// N is the number of students int n; cout << "Enter the number of students "; cin >> n; student s[n];

// taking the input for all the students for (int i = 0;i> s[i].test1 >> s[i].test2 >> s[i].lab >> s[i].quiz >> s[i].final; // Mulitply the final result by 0.1 because the grades are out of 10 and not out of 100 s[i].total = 0.1*(s[i].test1*0.2 + s[i].test2*0.2 + s[i].lab*0.15 + s[i].quiz*0.15 + s[i].final*0.3); s[i].grade = calcGrade(s[i].total); }

// printing the output cout << fixed << setprecision(2); cout << left << setw(30) << " Student Name" << setw(8) << "Test1" << setw(8) << "Test2" << setw(8) << "Lab" << setw(8) << "Quiz" << setw(8) << "Final" << setw(8) << "Total" << setw(8) << "Grade"; cout << endl << left << setw(30) << "============" << setw(8) << "=====" << setw(8) << "=====" << setw(8) << "===" << setw(8) << "====" << setw(8) << "=====" << setw(8) << "=====" << setw(8) << "=====" << endl; for (int i = 0;i

return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions