Computer Science Unit 1 IA Sample
Computer Science Unit 1 IA Sample
St. Elmo’s Preparatory School is located on the outskirts of the town of Santa Cruz. The
school has a maximum of 30 teachers dispersed among the classes according to their grade level.
The school has made a name for themselves based on their involvement in various sporting,
academic and social events. The school functions in between the hours of 8:00 am to 3:00 pm and
operates classes from kindergarten 1 to grade 6. The students that do all their various exams straight
up to GSAT always do their best to make their school, family and also themselves proud.
The main problem that the school faces is their submission of grades, since the beginning of
the school the teachers have been recording the student’s grades in registers and storing them in a
file cabinet which is neither fire nor waterproof. The teachers have also misplaced the registers,
have them destroyed by the students and even brought home by the teachers over the years.
However, a program has been made specifically for the inventory of all the grades. The
grade management system created is a soft copy made specifically for the teachers and principal to
use. Also, it’s been made very user friendly; which saves and stores the grades in the protected and
secured software. Thanks to the creation of this program, it has been efficient in the time teachers
take to input grades, not easily harmed by physical and software occurrences. This program allows
for the flow of grades to go very more smoothly and is less stressful for the teachers.
1|Page
Narrative
Main Function
This function displays the welcome screen then calls the login function.
Login Function
Upon entering correct user name and password, which are “Admin73” and password as “elmo036”,
a message telling user that login was successful, prompting the user to press any key to continue
would be displayed. Pressing any key would have taken user to main_menu function.
Upon entering incorrect username and/or password, a message telling user that login failed,
prompting the user to press any key to continue would have been displayed. Pressing any key would
have taken user to back to login function.
This function displays main menu options, prompting user to press 1 to Add Grade, 2 to View Grade,
3 to Print Report or 4 to Log Out. However, upon entering 4 program closes. Entering invalid choice
would tell user that there was an invalid choice prompting the user to press any key to continue,
which calls back main menu function.
Function displays the Add Grade screen where user was prompted to enter details about student
and their grades. Details included id number, first name, last name, middle name, class, maths,
language arts, social studies grades and science grade and accepts. The students averages were also
calculated.The student.txt file was then attempted to be opened and if not a message telling user,
“ERROR OPENING FILE!”, was then displayed. If file was opened new student grades were added to
file and closed, prompting the user to press any key to continue which took the user back to main
menu.
This function first checks if students.txt file could not be opened, and prints error message.
Otherwise, while not end of file read records, store in arrays and close file.
2|Page
View Grade Function
This function first calls the read grade Function. After which all students name, class, maths,
language arts, social studies, science and average details would be displayed. The user would also be
prompted to press any key to continue which took user back to main menu screen.
This function first prompts the user to enter student id number for search. After which, the read
grades function would be called. Matching record would be displayed and report printed, prompting
the user to press any key to continue which took user back to main menu screen.
3|Page
Pseudocode
Procedure Main
Declare maths, language arts, social studies, science, average as global real
Declare fname1, lname1, mn1, class1 as global string arrays of size 1000
Declare maths1, language arts, social studies1, science1, average1 as global real arrays of size 1000
Start
Print ( =================================================)
Print (*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''**)
Print (*''*''*''*''*'''*''*''*''*''*''*WELCOME*''*''*''*''**''**''**''**''**''**''***)
Print (*''*''*''*''*''*''*''*''*''*''*''*''TO''*''*''*''*''**''**''**''**''**''**''****)
Stop
Procedure login
Begin
Read(user_name)
Read(password)
4|Page
Print("LOGIN SUCCESSFUL")
else
Print("login failed")
End if
End
Procedure main_menu
Begin
Print (=================================================)
Print (*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''**)
Print (*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''**)
Print (=====================================================)
Print (====================================================)
Read (option)
CASE of option
case 1:
5|Page
break
case 2:
break
case 3:
break
case 4:
EXIT
default:
Print("INVALID OPTION.")
break
ENDCASE
End
Procedure add_grade
Begin
Read(idn)
Read(fname)
Read(lname)
Read(mn)
6|Page
Read(class)
Read(maths)
Read(spelling)
Read(ss)
Read(science)
Else
idnFile = idn
fnameFile = fname
lnameFile = lname
mnFile = mn
classFile = class
mathsFile = maths
socialstudiesFile = ss
scienceFile = science
averageFile = average
End If
End
7|Page
Procedure read_grade
Begin
idx 0
Else
While(<>EOF)do
idn1[idx]=idnFile
fname1[idx]=fnameFile
lname1[idx]=lnameFile
mn1[idx]=mnFile
class1[idx]=classFile
maths1[idx]=mathsFile
languagearts1[idx]=languageartsFile
socialstudies1[idx]=socialstudiesFile
science1[idx]=scienceFile
average1[idx]=averageFile
idx=idx+1
End While
End If
counter =idx
End
Procedure view_grade
8|Page
Declare x as integer
Begin
For(x=0 to counter-1)do
End For
End
Procedure printReport()
Begin
found 0
idx 0
Read(idn)
For(x=0 to counter-1)do
If(idn =idn1[x])then
found1
idxx
End If
End For
9|Page
If(found=1)then
Print("Mathematics Grade:”,maths1[idx])
Print("AVERAGE: “,average1[idx])
else
End If
End
10 | P a g e
ST. ELMO’S PREPARATORY SCHOOL GRADE MANAGEMENT SYSTEM
//Program Headers
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include <math.h>
#include <conio.h>
#include <ctype.h>
//declaration of structure
typedef struct{
char firstName[20];
char lastName[20];
char Class[2];
int id;
float grade_one;
float grade_two;
float grade_three;
float grade_four;
float average;
}student;//Declare structure
//globals
student sT[1000];
int counter=0;
11 | P a g e
//Function Prototype
void main_menu();
void add_student();
void read_grade();
void view_student();
void searchClass();
void printReport();
//Main function
system("mode 170");
main_menu();//Call Function
getch();
return 0;
//Welcome Function
system("color 3f");
system("color b7");
12 | P a g e
Sleep(150);
printf("\n\n\n\n\t\t=================================================");
printf("\n\n\n\t\t*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''** \n");
Sleep(150);
printf("\n\n\n\t\t*''*''*''*''*'''*''*''*''*''*''*WELCOME*''*''*''*''**''**''**''**''**''**''***\n");
Sleep(150);
printf("\n\n\n\t\t*''*''*''*''*''*''*''*''*''*''*''*''TO''*''*''*''*''**''**''**''**''**''**''****\n");
Sleep(150);
Sleep(150);
printf("\n\n\n\t\t*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''**\n ");
Sleep(150);
printf("\n");
printf("\t\t======================================================");
Sleep(150);
getch();
system ("cls");
//Login Function
void login(){
int b;
char a;
int counter;
13 | P a g e
system("cls");
printf("\n\n\n\n\t\t=================================================");
printf("\n\n\n\t\t*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''**
\n");
Sleep(150);
Sleep(150);
printf("\n\n\n\t\t*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''**\n ");
Sleep(150);
printf("\n\t\t=====================================================");
Sleep(150);
printf("\n\n\t\t LOGIN");
scanf("%s", userName);
a=getch();
if((a>='a'&&a<='z')||(a>='A'&&a<='Z')||(a>='0'&&a<='9'))
password[b]=a;
++b;
printf("*");
if(a=='\b'&&b>=1)
printf("\b \b");
--b;
14 | P a g e
}
break;
printf("\n\n\n\t\t\t\t\tLogin Successful!!!!!!!!");
getch();
system("cls");
}else{
getch();
login();
void main_menu(){
//Declare variables
int choice;
system("cls");
system("cls");
15 | P a g e
printf("\n\n\n\n\t\t=================================================");
printf("\n\n\t\t*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''** \n");
Sleep(150);
Sleep(150);
printf("\n\n\t\t*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''**\n ");
Sleep(150);
printf("\n\t\t=====================================================");
Sleep(150);
printf("\t\t====================================================\n\n");
switch (choice){
case 1:
add_student();//Call Function
break;
case 2:
view_student();//Call Function
break;
case 3:
16 | P a g e
searchClass();//Call Function
break;
case 4:
printReport();//Call Function
break;
default:
getch();
system("cls");
main_menu();//Call Function
break;
void add_student()
FILE * fp;
student sT;
system("cls");
//Display Headings
printf("\n\n\n\n\t\t=================================================");
printf("\n\n\t\t*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''** \n");
Sleep(150);
Sleep(150);
printf("\n\n\t\t*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''**\n ");
Sleep(150);
17 | P a g e
printf("\n\t\t====================================================");
Sleep(150);
system("color fd");
scanf("%i", &sT.id);
scanf("%s", sT.firstName);
scanf("%s", sT.lastName);
scanf("%s", sT.Class);
scanf("%f", &sT.grade_one);
scanf("%f", &sT.grade_two);
scanf("%f", &sT.grade_three);
scanf("%f", &sT.grade_four);
//calculate average
18 | P a g e
}else{
fprintf(fp,"%i\t%s\t%s\t%s\t%.1f\t%.1f\t%.1f\t%.1f\t%.1f\n", sT.id,sT.firstName,
sT.lastName, sT.Class, sT.grade_one, sT.grade_two, sT.grade_three, sT.grade_four, sT.average);
fclose(fp);//close file
getch();
system("cls");
main_menu();//Call Function
void read_grade(){
counter=0;
FILE*fp;//file pointer
}else{
fscanf(fp,"%i\t%s\t%s\t%s\t%f\t%f\t%f\t%f\t%f\n",
&sT[counter].id,sT[counter].firstName, sT[counter].lastName, sT[counter].Class,
&sT[counter].grade_one, &
sT[counter].grade_two,&sT[counter].grade_three,&sT[counter].grade_four, & sT[counter].average);
counter++;
19 | P a g e
fclose(fp); //close file
//View Function
void view_student()
system("cls");
read_grade();//Call Function
printf("\n\n\n\n\t\t================================================");
printf("\n\n\t\t*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''** \n");
Sleep(150);
Sleep(150);
printf("\n\n\t\t*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''**\n ");
Sleep(150);
printf("\n\t\t=================================================\n");
Sleep(150);
Sleep(150);
printf("\n\t\t===================================================");
printf("\n\t\t=====================================================");
20 | P a g e
printf("\n\t\t%i\t%s,%s\t%s\t%.1f\t\t%.1f\t%.1f\t%.1f\t%.1f",
sT[i].id,sT[i].firstName, sT[i].lastName, sT[i].Class, sT[i].grade_one, sT[i].grade_two,
sT[i].grade_three, sT[i].grade_four,sT[i].average );
printf("\n\t\t========================================");
getch();
main_menu();//Call Function
void searchClass(){
int i, found=0;
system("cls");
read_grade();//Call Function
printf("\n\n\n\n\t\t=================================================");
printf("\n\n\t\t*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''** \n");
Sleep(150);
Sleep(150);
printf("\n\n\t\t*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''**\n ");
Sleep(150);
printf("\n\t\t==========================================\n");
Sleep(150);
21 | P a g e
Sleep(150);
printf("\n\t\t=====================================================");
scanf("%s", sClass);
printf("\n\t\t=====================================================");
printf("\n\t\t===================================================");
//display records
// Check Record
if(strcmp(sClass, sT[i].Class)==0){
//Print Record
printf("\n\t\t%i\t%s,%s\t%s\t%.1f\t\t%.1f\t%.1f\t%.1f\t%.1f",
sT[i].id,sT[i].firstName, sT[i].lastName, sT[i].Class, sT[i].grade_one, sT[i].grade_two,
sT[i].grade_three, sT[i].grade_four,sT[i].average );
printf("\n\t\t==================================");
found=1;
if (found!=1){
getch();
main_menu();//Call Function
22 | P a g e
void printReport(){
int i, found=0,id;
system("cls");
read_grade();//Call Function
printf("\n\n\n\n\t\t================================================");
printf("\n\n\t\t*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''** \n");
Sleep(150);
Sleep(150);
printf("\n\n\t\t*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''**\n ");
Sleep(150);
printf("\n\t\t====================================================\n");
Sleep(150);
Sleep(150);
printf("\n\t\t=====================================================");
scanf("%i", &id);
//display records
// Check Record
if(id==sT[i].id){
//Display Headings
system("cls");
23 | P a g e
printf("\n\n\n\n\t\t=================================");
printf("\n\n\t\t*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''** \n");
Sleep(150);
Sleep(150);
printf("\n\n\t\t*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''**\n ");
Sleep(150);
printf("\n\t\t=====================================\n");
Sleep(150);
Sleep(150);
printf("\n\t\t=====================================");
//print record
printf("\n\n\t\t\t\t\tClass : %s",sT[i].Class);
printf("\n\n\t\t\t\t\tMathsGrade : %.1f",sT[i].grade_one);
printf("\n\n\t\t\t\t\tAverage : %.1f",sT[i].average);
printf("\n\n\t\t=============================================");
found=1;
if (found!=1){
24 | P a g e
}
getch();
main_menu();//Call Function
25 | P a g e
Test Plan
LOGIN FUNCTION
VARIABLE TEST TEST PURPOSE OF USER’S EXPECTED ACTUAL RESULT
NAME TYPE DATA DATA RESULT
Username String Admin73 To store the user The program prompts The program prompts
name of user. user to enter the user to enter the
password for login. password for login.
Password String elmo036 To allow program The program prompts The program prompts
to store the users user to press any key user to press any key
password. to continue which calls to continue which calls
the main menu the main menu
function. function.
Input Output
4 Exit Program
26 | P a g e
ADD GRADE SCREEN
Input Output
Print Report Screen
Id Displays Id then prompt for first name.
Input
First Name
Output
Displays first name then prompt for last name
Displays report with matching record, prompting user to
Last Name Displays last name then prompt for middle name.
Id number matched in the database. press any key to continue which takes user back to main
Middle Name Displays middle name then prompt for class.
menu.
Language Arts Grade Displays Language Arts then prompt for Grammar Grade
27 | P a g e
28 | P a g e
29 | P a g e
30 | P a g e
31 | P a g e
32 | P a g e
33 | P a g e