Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CS 210 – Programming and Data Structures - Student Records Database A database i

ID: 3693965 • Letter: C

Question

CS 210 – Programming and Data Structures - Student Records Database

A database is one of the most powerful applications of computer technology. A database enables users to organize large quantities of data and to ask questions about it. Behind every interactive website, there is a database storing the data associated with that site. There are a number of commercial and free database packages available, including Access, MySQL, SQL Server, and Oracle. As a computer scientist, you have an opportunity to take a very interesting and useful course called CS 330: Database Systems. In this assignment, you will create your own database system, one that helps us answer questions about students and their GPAs.

Our “database” will be a text file. The text file has the following format:

Name Code GPA

The name field stores the name of the student. The GPA field stores the student’s GPA. The Code field stores demographic data about the student in a very compact way. The code consists of 5 characters, in this order:

Gender, (M or F)

Race / Ethnicity (W for white, B for Black / African-American, H for Hispanic, A for Asian, O for other

Location (R for residential, C for commuter)

College (A for Arts and Sciences, B for Business, E for Education, N for Nursing)

Year (1 for freshman, 2 for sophomore, 3 for junior, 4 for senior, G for grad)

Here’s an example of a data file formatted in this way:

Joe MWCA3 3.42

Fred MARB4 2.75

Kris FWCB3 3.12

Sonia FHCA2 3.51

Tom MWRE3 3.91

Frank MHRA3 3.55

Ally FBRA4 3.14

Ed MWCN1 2.79

Nina FHRA3 3.74

Jasmine FBCB4 3.28

Alex MWRAG 3.12

Robert MBCE2 3.07

Simone FWRE3 3.19

Ray MWCA2 2.74

Steve MWCA3 2.99

One use of this database system is to link GPA with demographic information. The user will be able to ask questions such as “What is the average GPA for all male business majors” and “What is the average GPA for all female African-American or Hispanic Commuter students.” Even with this rather limited data set, we can ask very specific questions.

We will write a program that will read this data and then enable users to compute average GPA values for specific subgroups of people. We won’t ask quite as specific kinds of questions as we could, for we will limit ourselves to asking questions that identify people that meet only one condition per category. In other words, we won’t ask if someone is either white or Hispanic, or either in Nursing or Arts and Sciences. Instead, we will ask whether they meet on of the conditions in each category. This will simply the logic considerably.

Your program will read the file of student data. It will then have the user specify which records he is interested in by asking him to answer a series of questions. Specifically, the user will be asked to specify the gender, ethnicity, residential status, college, and year. If the user doesn’t care about the answer to a particular question (for example, he wants all students, regardless of their gender), then he will enter an asterisk. After the user answers these questions, the program will show a list of all students who match these critiera. It will then show the average gpa for those students. The program will then ask the user if he wants to identify a different set of students. If he does, the program will repeat the process. The program ends when the user indicates he wants to quit.

Here is an example of the output your program should produce:

Welcome to GPA Calculator

This program computes the GPA of groups of students

based on data about individual student demographics

and GPAs read from a text file. It implements the kind

of functionality you might find from a modern database.

Enter the name of the data file: c: empgpa.txt

This is the data that was read from the file:

Joe         MWCA3         3.42

Fred        MARB4         2.75

Kris        FWCB3         3.12

Sonia       FHCA2         3.51

Tom         MWRE3         3.91

Frank       MHRA3         3.55

Ally        FBRA4         3.14

Ed          MWCN1         2.79

Nina        FHRA3         3.74

Jasmine     FBCB4         3.28

Alex        MWRAG         3.12

Robert      MBCE2         3.07

Simone      FWRE3         3.19

Ray         MWCA2         2.74

Steve       MWCA3         2.99

Enter demographic data for which to find average GPA:

Gender

M for Male, F for Female,

* for either: M

Race/Ethnicity

W for White, B for African/American,

H for Hispanic, A for Asian,

O for other, * for any: W

Location

R for residential, C for commuter

* for either: *

College

A for Arts and Sciences, B for Business,

E for Education, N for Nursing,

* for any: A

Year

1 for Freshman, 2 for Sophomore,

3 for Junior, 4 for Senior,

G for Grad, * for any: *

The following students meet those criteria:

Joe           3.42

Alex          3.12

Ray           2.74

Steve         2.99

The average GPA for that demographic is   3.07.

Would you like to compute another (Y or N)? Y

Enter demographic data for which to find average GPA:

Gender

M for Male, F for Female,

* for either: F

Race/Ethnicity

W for White, B for African/American,

H for Hispanic, A for Asian,

O for other, * for any: B

Location

R for residential, C for commuter

* for either: *

College

A for Arts and Sciences, B for Business,

E for Education, N for Nursing,

* for any: *

Year

1 for Freshman, 2 for Sophomore,

3 for Junior, 4 for Senior,

G for Grad, * for any: *

The following students meet those criteria:

Ally          3.14

Jasmine       3.28

The average GPA for that demographic is   3.21.

Would you like to compute another (Y or N)? Y

Enter demographic data for which to find average GPA:

Gender

M for Male, F for Female,

* for either: *

Race/Ethnicity

W for White, B for African/American,

H for Hispanic, A for Asian,

O for other, * for any: *

Location

R for residential, C for commuter

* for either: R

College

A for Arts and Sciences, B for Business,

E for Education, N for Nursing,

* for any: B

Year

1 for Freshman, 2 for Sophomore,

3 for Junior, 4 for Senior,

G for Grad, * for any: *

The following students meet those criteria:

Fred          2.75

The average GPA for that demographic is   2.75.

Would you like to compute another (Y or N)? Y

Enter demographic data for which to find average GPA:

Gender

M for Male, F for Female,

* for either: *

Race/Ethnicity

W for White, B for African/American,

H for Hispanic, A for Asian,

O for other, * for any: *

Location

R for residential, C for commuter

* for either: *

College

A for Arts and Sciences, B for Business,

E for Education, N for Nursing,

* for any: *

Year

1 for Freshman, 2 for Sophomore,

3 for Junior, 4 for Senior,

G for Grad, * for any: G

The following students meet those criteria:

Alex          3.12

The average GPA for that demographic is   3.12.

Would you like to compute another (Y or N)? N

Your program will be graded as follows:

Your program prints an introductory greeting for the user. 1 point

Your program asks the user for the file to open and correctly opens it. 1 point

Your program reads the records in the file into parallel arrays. 2 points

Your program correctly prints out the student data to the screen 2 points

Your program repeatedly asks the user to specify selection criteria until he indicates he wants to quit. 1 point

Your program correctly selects based on gender. 1 point

Your program correctly selects based on ethnicity. 1 point

Your program correctly selects based on residential status. 1 point

Your program correctly selects based on college. 1 point

Your program correctly selects based on year. 1 point

Your program lists selected students and their gpa to the screen 2 points

Your program correctly computes the average gpa. 2 points

Your program reports 0 as the average gpa if no students match the selected criteria (instead of trying to divide by 0). 1 point

Your program makes use of multiple functions (for example, to print the intro, to print the records, and to select the matching student records). 2 points

Your code is well-documented, properly indented, uses self-explanatory variable names, and is easy-to-follow. 1 point

Explanation / Answer

Actually i am not that good at SQL.I have done using simple java script. I got little confused with your question.My code code dosent consists of any gender or Race/Ethnicity.so ,once have a glance at the code.It might help you.

<html>

<head>

<title>CgpaCalcualtor</title>

<nav class="navbar navbar-inverse" role="navigation">

<div>

<ul class="nav navbar-nav">

<li class="active"><a href="#"> CgpaCalculator</a></li>

</ul>

</div>

</nav>

<div class="container" >

<div class="jumbotron">

<center><h1>CGPA CALCULATOR</center></h1>

  

</div>

</div>

<meta name="viewport" content="width=device-width, initial-scale=1.0">

  

<link href="C:UsersphaniDesktopphaniproject/bootstrap-3.3.5-dist/css/bootstrap.min.css" rel="stylesheet">

<style>

input { width:100% }

body {

background-color: #9ba8ea

;

}

</style>

<script>

function verifysub()

{

var name=document.getElementById("count1a").value;

if(name=="")

{

}

else if(name<=0||name>10)

{

this.value="";

//this.setAttribute("placeholder", "No of subjects between 1 to 10 ");

alert("Invalid input,please enter numbers between 1 to 10");

}

}

function verifycredit()

{

var name=document.getElementById("count1b").value;

if(name=="")

{

}

else if(name<=0||name>10)

{

this.value="";

//this.setAttribute("placeholder", "No of subjects between 1 to 10 ");

alert("Invalid input,please enter numbers between 1 to 10");

}

}

function change() //for reset button

{

var stable=document.getElementById("subjectsTable");

var subrows=stable.rows.length;

subrows--;

for(var k=subrows;k>1;k--)

{

stable.deleteRow(k);

}

document.getElementById("count1a").value="";

document.getElementById("count1b").value="";

addGrades();

}

function addSubjects() //for adding other credit subjects

{

var table=document.getElementById("subjectsTable");

var rowcount=table.rows.length;

var num=rowcount-1;

var subid='count'+num+'a';

var creditid='count'+num+'b';

var sub=document.getElementById(subid).value;

var credit=document.getElementById(creditid).value;

if(sub==""||credit=="")

{

alert("fields left blank");

}

else

{

var row=table.insertRow(rowcount);

var cell1=row.insertCell(0);

var cell2=row.insertCell(1);

var el=document.createElement('input');

el.type='number';

el.id='count'+rowcount+'a';

el.min=1;

el.max=10;

el.onkeyup=function()

{

var name=this.value;

if(name<=0||name>10)

{

this.value="";

//this.setAttribute("placeholder", "No of subjects between 1 to 10 ");

alert("Invalid input,please enter numbers between 1 to 10");

}

}

var el1=document.createElement('input');

el1.type='number';

el1.id='count'+rowcount+'b';

el1.min="1";

el1.max="10";

el1.onkeyup=function()

{

var name=this.value;

if(name<=0||name>10)

{

this.value="";

//this.setAttribute("placeholder", "Entered ");

alert("Invalid input, please enter number between 1 to 10");

}

}

cell1.appendChild(el);

cell2.appendChild(el1);

}

}

function addGrades() //for creating grade table

{

var gtable=document.getElementById("gradeTable");

var grows=gtable.rows.length;

grows--;

for(var k=grows;k>0;k--)

{

gtable.deleteRow(k);

}

var stable=document.getElementById("subjectsTable");

var rowcount=stable.rows.length;

var counter=0;

for(var i=1;i<rowcount;i++)

{

var name1='count'+i+'a';

var name2='count'+i+'b';

var subCount=document.getElementById(name1).value;

var credits=document.getElementById(name2).value;

for(var j=1;j<=subCount;j++)

{

var growcount=gtable.rows.length;

var row=gtable.insertRow(growcount);

var cell1=row.insertCell(0);

var cell2=row.insertCell(1);

var cell3=row.insertCell(2);

counter++;

var el=document.createElement('input');

el.type='text';

el.id='grade'+counter;

el.onkeyup=function()

{

var name=this.value;

if(name!='a'&&name!='b'&&name!='c'&&name!='d'&&name!='e'&&name!='o'&&name!='f'&&name!='A'&&name!='B'&&name!='C'&&name!='D'&&name!='E'&&name!='O'&&name!='F')

{

this.value="";

this.setAttribute("placeholder", "Entered Invalid Grade");

}

}

cell1.innerHTML="subject"+counter;

cell2.innerHTML=credits;

cell3.appendChild(el);

}

}

}

function entryTest()

{

var stable=document.getElementById("subjectsTable");

var rowcount=stable.rows.length;

var flag=0;

for(var i=1;i<rowcount;i++)

{

var name1='count'+i+'a';

var name2='count'+i+'b';

var subCount=document.getElementById(name1).value;

var credits=document.getElementById(name2).value;

if(subCount==""||credits=="")

{

flag=1;

break;

}

}

if(flag==1)

{

alert("fields should not left blank");

}

else

{

addGrades();

}

}

function sgpa()

{

var gtable=document.getElementById("gradeTable");

var count=gtable.rows.length;

if(count==1)

{

alert("Grades Not Entered");

return;

}

var stable=document.getElementById("subjectsTable");

var rowcount=stable.rows.length;

var counter=0;

var creditCount=0;

var pointsCount=0;

for(var i=1;i<rowcount;i++)

{

var name1='count'+i+'a';

var name2='count'+i+'b';

var subCount=document.getElementById(name1).value;

var credits=document.getElementById(name2).value;

var flag=0;

for(var j=1;j<=subCount;j++)

{

counter++;

creditCount=Number(creditCount)+Number(credits);

var gradename='grade'+counter;

var igrade=document.getElementById(gradename).value;

var grade=igrade.toLowerCase();

if(grade=='o')

{

pointsCount=Number(pointsCount)+credits*10;

}

else if(grade=='a')

{

pointsCount=Number(pointsCount)+credits*9;

}

else if(grade=='b')

{

pointsCount=Number(pointsCount)+credits*8;

}

else if(grade=='c')

{

pointsCount=Number(pointsCount)+credits*7;

}

else if(grade=='d')

{

pointsCount=Number(pointsCount)+credits*6;

}

else if(grade=='e')

{

pointsCount=Number(pointsCount)+credits*5;

}

else

{

flag=1;

break;

}

}

if(flag==1)

{

pointsCount=0;

break;

}

}

var sgpa=pointsCount/creditCount;

var rsgpa=sgpa.toFixed(2);

var stable=document.getElementById("sgpaTable");

var row=stable.insertRow(0);

var cell1=row.insertCell(0);

var cell2=row.insertCell(1);

var cell3=row.insertCell(2);

var cell4=row.insertCell(3);

var cell5=row.insertCell(4);

var el=document.createElement('input');

el.type='button';

el.value='remove';

el.onclick=function()

{

var r=el.parentElement.parentElement;

document.getElementById("sgpaTable").deleteRow(r.rowIndex);

cgpa();

}

cell1.innerHTML="Your SGPA =";

cell2.innerHTML=rsgpa;

cell3.appendChild(el);

var el1=document.createElement('input');

el1.type='hidden';

el1.value=pointsCount;

el1.name='pointsCount';

cell4.appendChild(el1);

var el2=document.createElement('input');

el2.type='hidden';

el2.value=creditCount;

el2.name='creditCount';

cell5.appendChild(el2);

cgpa();

}

function cgpa()

{

var table=document.getElementById("sgpaTable");

var rowCount=table.rows.length;

var pointsum=0;

var creditsum=0;

var x=document.getElementsByName("pointsCount");

var y=document.getElementsByName("creditCount");

for(var i=0;i<rowCount;i++)

{

var sgpa=table.rows[i].cells[1].innerHTML;

if(Number(sgpa)==0)

{

pointsum=0;

break;

}

pointsum=Number(pointsum)+Number(x[i].value);

creditsum=Number(creditsum)+Number(y[i].value);

}

var icgpa=Number(pointsum)/Number(creditsum);

var cgpa=icgpa.toFixed(2);

document.getElementById("cgpaValue").innerHTML=cgpa;

var percentage=cgpa*10;

var fper=percentage.toFixed(1);

document.getElementById("perValue").innerHTML=fper+"%";

}

</script>

</head>

<body >

<br><br>

<table border=1 align="center" id="subjectsTable" class="table">

<tr>

<th>No.of subjects

<th>No.of credits

</tr>

<tr>

<td><input type="number" min="1" max="10" id="count1a">

<td><input type="number" min="1" max="10" id="count1b">

</tr>

</table>

<table align="center">

<tr>

<td><input type="submit" value="reset" class="btn btn-danger">

<td><input type="submit" value="add another credit subjects" class="btn btn-primary">

<td><input type="submit" value="enter grades" class="btn btn-success">

</tr>

</table><br><br>

<table align="center" id="gradeTable" border=1 class="table" >

<tr>

<th>subjects

<th>credits

<th>Enter Grades (O,A,B,C,D,E)

</tr>

</table>

<table align="center">

<tr>

<td><input type="submit" value="reset" class="btn btn-danger">

<td><input type="submit" value="calculate sgpa" class="btn btn-success">

</table><br>

<table align="center" id="sgpaTable">

</table>

<br><br><hr>

<table align="center" id="cgpaTable">

<tr>

<td>Your CGPA=

<td id="cgpaValue">0.00

</table>

<table align="center" id="percentage">

<td>Your Percentage=

<td id="perValue">0.00

</table><hr>

<h5>* percentage is calculated by multiplying cgpa with 10

</body>

</html>