0% found this document useful (0 votes)
353 views

CCS0007 Midterm Machine ProblemBSVZamora 1

The document describes a midterm machine problem assignment to create a C++ student database management system. It provides requirements for the program, including defining a student structure with fields for ID, name, GPA. It outlines functions for adding students, displaying students, calculating average GPA, and finding students by last name. The main program is to initialize an array of students and implement a menu-driven interface with options to perform the above functions and exit. Source code and output screenshots are to be submitted.

Uploaded by

brandonsydzamora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
353 views

CCS0007 Midterm Machine ProblemBSVZamora 1

The document describes a midterm machine problem assignment to create a C++ student database management system. It provides requirements for the program, including defining a student structure with fields for ID, name, GPA. It outlines functions for adding students, displaying students, calculating average GPA, and finding students by last name. The main program is to initialize an array of students and implement a menu-driven interface with options to perform the above functions and exit. Source code and output screenshots are to be submitted.

Uploaded by

brandonsydzamora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Department of Information Technology

CCS0007 – COMPUTER PROGRAMMING 2

[SECTION]

Midterm Machine Problem

Grade

Submitted by:

<Zamora, Brandon Syd V. >

Submitted to

<Jabez Mendoza>

Submitted on:

<02/08/2024>
I. Machine Problem 1

Title: Student Database Management System

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:

Create a structure named Student with the following members:

• int studentID
• char firstName[50]
• char lastName[50]
• float GPA

Function Definitions:

a. void addStudent(Student students[], int &numStudents)

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.

Display the details of all students in a formatted tabular manner.

c. float calculateAverageGPA(const Student students[], int numStudents)

This function should take the array of Student structures and the total number of
students as parameters.

Calculate and return the average GPA of all students.

d. void findStudentsByLastName(const Student students[], int numStudents, const char


lastName[])

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;

// stucture of students information


struct student{
int studentID;
char firstname[50];
char lastname[50];
float gpa;
};

// Function for adding new students


void addStudents(Student students[100], int &numStudents){
Students students;
cout << "Enter Firstname: " <<endl;
cin >> student.firstname;
cout << "Enter Lastname: " <<endl;
cin >> student.lastname;
cout << "Enter Studentid: " <<endl;
cin >> student.studentID;

// display arrays of students records (Not finish yet hahahahaha)


void displayStudents(const Student students[100], int numstudents){
cout << "Displaying Total Number of Students: " <<endl;

for (int i = 0; i < 100; i++)


{
cout << "Student " << i + 1 <<": " << students[i] <<endl;
}

}
// 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

TRAIT Exceptional Acceptable Amateur Unsatisfactory


The program works
and produces the The program
correct results and produces
Specifications The program works The program is
displays them correct results
and meets all of the producing incorrect
(20) correctly. It also but does not
specifications. results.
meets most of the display them
other correctly.
specifications.
The code is
The code is readable only by
Readability The code is poorly
exceptionally well The code is fairly someone who
organized and very
(20) organized and very easy to read. knows what it is
difficult to read.
easy to follow. supposed to be
doing.
The code could be Some parts of
Reusability Most of the code The code is not
reused as a whole the code could
could be reused in organized for
(20) or each routine be reused in
other programs. reusability.
could be reused. other programs.
The
The documentation
documentation
consists of
is simply
The documentation embedded The documentation is
comments
is well written and comment and simply comments
Documentation embedded in
clearly explains some simple embedded in the code
the code with
(30) what the code is header and does not help the
some simple
accomplishing and documentation that reader understand the
header
how. is somewhat useful code.
comments
in understanding
separating
the code.
routines.
The code is The code is fairly
The code is
Efficiency extremely efficient efficient without The code is huge and
brute force and
without sacrificing sacrificing appears to be patched
(10) unnecessarily
readability and readability and together.
long.
understanding. understanding.

You might also like