Itc Finale
Itc Finale
Program execution
begins and ends there.
//
#include <iostream>
using namespace std;
int main()
{
const int ARRAY_SIZE = 100;
int rollNumbers[ARRAY_SIZE] = { 73, 42, 91, 28, 15, 68, 37, 54, 89, 63, 12,
76, 98, 24, 51, 84, 19, 33, 77, 46, 59, 81, 36, 22, 67, 93, 58, 14, 72, 31, 88, 49,
26, 61, 82, 18, 95, 29, 44, 71, 97, 23, 39, 66, 13, 78, 55, 86, 32 };
int studentClass[ARRAY_SIZE] = { 3, 2, 1, 3, 2, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1,
2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2,
3, 1, 2, 3, 1, 2, 3, 1 };
char grades[ARRAY_SIZE] = { 'B', 'C', 'A', 'B', 'C', 'A', 'C', 'B', 'A', 'B',
'A', 'C', 'B', 'A', 'B', 'C', 'A', 'B', 'C', 'B', 'A', 'C', 'B', 'A', 'C', 'B',
'A', 'C', 'B', 'A', 'C', 'B', 'A', 'C', 'B', 'A', 'C', 'B', 'A', 'C', 'B', 'A',
'C', 'B', 'A', 'C', 'B', 'A', 'C', 'B', 'A' };
char choice;
int curr_size = 50;
do {
cout << "\nMain Menu:\n";
cout << "Press 'A' to Sort and display all records roll number wise in
ascending order.\n";
cout << "Press 'B' to Sort and display all records roll number wise in
descending order.\n";
cout << "Press 'C' to Sort and display all records in ascending order
based on marks in Midterm.\n";
cout << "Press 'D' to Sort and display all records in descending order
based on marks in Midterm.\n";
cout << "Press 'F' to Sort and display all records in ascending order
based on marks in Final.\n";
cout << "Press 'G' to Sort and display all records in descending order
based on marks in Final.\n";
cout << "Press 'H' to Sort and display all records in ascending order
based on Grade.\n";
cout << "Press 'I' to Sort and display all records in descending order
based on Grade.\n";
cout << "Press 'J' to Add a new entry of a student.\n";
cout << "Press 'K' to Delete a student record based on his roll
number.\n";
cout << "Press 'L' to Display record of all the students greater than X
marks in final exam (in descending order with respect to marks obtained in final
exam).\n";
cout << "Press 'M' to Display record of all the students greater than X
marks in final exam (in ascending order with respect to marks obtained in final
exam).\n";
cout << "Press 'N' to Display record of all the students less than or
equal to X marks in final exam (in descending order with respect to marks obtained
in final exam).\n";
cout << "Press 'O' to Display record of all the students less than or
equal to X marks in final exam (in ascending order with respect to marks obtained
in final exam).\n";
cout << "Press 'P' to Display record of all the students greater than X
grade (in descending order with respect to grade).\n";
cout << "Press 'Q' to Display record of all the students greater than X
grade (in ascending order with respect to grade).\n";
cout << "Press 'R' to Display record of all the students less than or
equal to X grade (in descending order with respect to grade).\n";
cout << "Press 'S' to Display record of all the students less than or
equal to X grade (in ascending order with respect to grade).\n";
cout << "Press 'E' to Exit\n";
cout << "Enter your choice: ";
cin >> choice;
if (deleteIndex != -1)
{
// Shift the entries to remove the record
for (int i = deleteIndex; i < curr_size - 1; ++i)
{
rollNumbers[i] = rollNumbers[i + 1];
midtermMarks[i] = midtermMarks[i + 1];
finalMarks[i] = finalMarks[i + 1];
studentClass[i] = studentClass[i + 1];
grades[i] = grades[i + 1];
}
cout << "Enter the threshold for final exam marks: ";
cin >> threshold;
std::cout << "\nRecords with Final Exam Marks greater than " <<
threshold << " (Descending Order):\n";
break;
case 'M':
// Display record of all the students greater than X marks in
final exam (in ascending order with respect to marks obtained in final exam)
cout << "Enter the threshold for final exam marks: ";
cin >> threshold;
cout << "\nRecords with Final Exam Marks greater than " <<
threshold << " (Ascending Order):\n";
// Bubble sort in ascending order based on finalMarks
for (int i = 0; i < curr_size - 1; ++i)
{
for (int j = 0; j < curr_size - i - 1; ++j)
{
if (finalMarks[j] > finalMarks[j + 1])
{
// Swap the records manually
int tempRoll = rollNumbers[j];
rollNumbers[j] = rollNumbers[j + 1];
rollNumbers[j + 1] = tempRoll;
cout << "Enter the threshold for final exam marks: ";
cin >> threshold;
cout << "\nRecords with Final Exam Marks less than or equal to "
<< threshold << " (Descending Order):\n";
cout << "Enter the threshold for final exam marks: ";
cin >> threshold;
cout << "\nRecords with Final Exam Marks less than or equal to "
<< threshold << " (Ascending Order):\n";
cout << "\nRecords with Grade greater than " << thres << "
(Descending Order):\n";
cout << "\nRecords with Grade greater than " << thres << "
(Ascending Order):\n";
break;
case 'R':
// Display record of all the students less than or equal to X
grade (in descending order with respect to grade)
float thres;
cout << "Enter the threshold grade (character): ";
cin >> thres;
std::cout << "\nRecords with Grade less than or equal to " <<
thres << " (Descending Order):\n";
cout << "\nRecords with Grade less than or equal to " << thres <<
" (Ascending Order):\n";
break;
case 'E':
case 'e':
cout << "Exiting the program.\n";
break;
default:
cout << "Invalid choice. Please enter a valid option.\n";
}
return 0;
}