CCS0007 Midterm Machine ProblemBSVZamora 1
CCS0007 Midterm Machine ProblemBSVZamora 1
[SECTION]
Grade
Submitted by:
Submitted to
<Jabez Mendoza>
Submitted on:
<02/08/2024>
I. Machine Problem 1
Problem Statement:
You are tasked with creating a simple Student Database Management System in C++
that allows users to store and manipulate student information. The program should utilize
user-defined functions, arrays, character and string manipulation, as well as structures.
Requirements:
Student Structure:
• int studentID
• char firstName[50]
• char lastName[50]
• float GPA
Function Definitions:
This function should take as parameters an array of Student structures (students) and an
integer reference (numStudents) indicating the current number of students in the
database.
It should prompt the user to input details for a new student and store them in the array.
b. void displayStudents(const Student students[], int numStudents)
This function should take the array of Student structures and the total number of
students as parameters.
This function should take the array of Student structures and the total number of
students as parameters.
This function should take the array of Student structures, the total number of students,
and a last name as parameters.
Display the details of students whose last name matches the given input.
Main Program:
In the main program, create an array of Student structures to hold up to 100 students.
Initialize the numStudents variable to 0. Implement a menu-driven program with the
following options:
• Add Student
• Display All Students
• Calculate Average GPA
• Find Students by Last Name
• Exit
Utilize the functions defined above to perform the corresponding actions for each menu
option.
Note: Ensure you perform necessary input validation and handle edge cases gracefully
(e.g., when the user tries to add more students than the array can hold).
II. Submission
Paste the source code and include 4 screenshots of the program output here.
//BSVZamora_=][=
#include <iostream>
#include <string>
#include <vector>
using namespace std;
}
// Area where the program calculate the average gpa
float calculateAverageGpa(conts Student students[100], int numstudents){
return (students.gpa[0] + students.gpa[1]) / 2.0;
}
// where the program will find the students by there last name
void findStudentsByLastName(const Student students[100], int numstudents, const char
lastname[]){
// main area
int main(){
vector<Student> students;
int choice;
//main menu where the user has a choice to add, calculate the average of their GPA
//, find the student by there lastname.
while (true)
{
cout << "=============================" <<endl;
cout << "Menu" <<endl;
cout << "=============================" <<endl;
cout << "1. Add Students: " <<endl;
cout << "2. Display all Students: " <<endl;
cout << "3. Calculate Average GPA: " <<endl;
cout << "4. Find Students By Lastname: " <<endl;
cout << "5. Exit program: "<<endl;
cin >> choice;
switch (choice)
{
case 1:
addStudents(students)
break;
case 2:
displayStudents(students)
break;
case 3:
calculateAverageGpa(students)
break;
case 4:
findStudentsByLastName(students)
break;
case 5:
cout << "Exiting Program. "<<endl;
return 0;
default:
cout << "Invadlid choice. " <<endl;
}
}
III. Rubrics