Using the Student Enrollment Record Set , write a program that determines how many males and females
Question:
Using the Student Enrollment Record Set, write a program that determines how many males and females live in each of the Zip Code areas. Output the zip code, the total number of males, and the total number of females for each zip code. At the end of the report display a total of males and females.
There are 5 zip codes in the record set. The zip codes are : 53711, 53712, 53713, 53714, 53716. These zip code values are self-evident as zip codes, and may be used as literals within the program (this an exception to the general course standard).
There must be at least four functions in this program for full credit. The existing function named,part04() is the first one. You must create at least three new additional functions for the program.
This program MUST be set up so that it reads through the Student Enrollment records just ONCE.
this is the sample output
53711: Males: 5 Females: 2
53712: Males: 9 Females: 9
53713: Males: 11 Females: 3
53714: Males: 4 Females: 6
53716: Males: 1 Females: 0
Total Males: 30
Total Females: 20
Student Enrollment Records Layout
Field 1 Field 2 Field 3 Field 4 Field 5 Field 6
Student Number Student Name Address Zip Code Gender Course Number
Using the Student Enrollment Records
The records are made available to your programs with this function:
openStudentEnrollmentRecords();
The function returns the records so you need to store them in a variable:
// using the open function
let studentRecords;
studentRecords = openStudentEnrollmentRecords();
After the openStudentEnrollmentRecords() function has been run you have access to the first record's data. You will retrieve each part of one record with a different function. Here are the functions:
studentRecords.getStudentNumber();
studentRecords.getStudentName();
studentRecords.getStudentAddress();
studentRecords.getStudentZipCode();
studentRecords.getStudentGender();
studentRecords.getStudentCourseNumber();
Notice that you need to have "studentRecords." in front of each of the functions.
When you want to read the next record you use the following function. It will make the next record available and you then use the above functions to retrieve the data. This function returns true if there was a next record and false if the end of the record set has been reached.
studentRecords.readNextRecord();
Example Usage
Here's an example of how the Student Enrollment Records are used.
/*
This is the JavaScript code for "Student Enrollment Records"
File: /unit04/studentEnrollmentRecords.html
*/
function studentEnrollmentRecords() {
"use strict";
//Declare Variables
let currentNumber;
let currentName;
let currentAddress;
let currentZipCode;
let currentGender;
let currentCourseNumber;
let studentRecords;
// Open the Student Enrollment Records and make them
// available to the script
studentRecords = openStudentEnrollmentRecords();
// Read the next record, test to see if there
// is a next record and then output it
while (studentRecords.readNextRecord()) {
currentNumber = studentRecords.getStudentNumber();
currentName = studentRecords.getStudentName();
currentAddress = studentRecords.getStudentAddress();
currentZipCode = studentRecords.getStudentZipCode();
currentGender = studentRecords.getStudentGender();
currentCourseNumber = studentRecords.getStudentCourseNumber();
// Display the second record
document.write(currentNumber + "t" + currentName + "t"
+ currentAddress + "t" + currentZipCode + "t"
+ currentGender + "t" + currentCourseNumber + "
");
}
}
Student Enrollment Record Data¶
101 Joe Coyne 123 Some St. 53711 M 18500
102 Fred Hensen 2205 Grand St. 53712 M 18500
103 Ethel Roselle 190 Fox St. 53713 F 18530
104 Barney Curry 1600 Ash St. 53714 M 18520
105 Wilma Hilgart 2205 Grand St. 53712 F 18540
106 Greg Statz 190 Fox St. 53713 M 18500
107 Mark Stanley 2205 Grand St. 53712 M 18500
108 Sandy Flynn 1600 Ash St. 53714 F 18530
109 Chris Foley 190 Fox St. 53713 M 18520
110 Dan Bristol 123 Some St. 53716 M 18500
111 Don Buell 190 Fox St. 53713 M 18540
112 Glen Doran 2205 Grand St. 53712 M 18500
113 Bill Gardiner 123 Some St. 53711 M 18520
114 Karen Mack 190 Fox St. 53713 F 18500
115 Dianne Klein 2205 Grand St. 53712 F 18530
116 Dawn Tillman 1600 Ash St. 53714 F 18500
117 Ed O'Connor 190 Fox St. 53713 M 18500
118 Hugo Matson 2205 Grand St. 53712 M 18500
119 Dave Koch 1600 Ash St. 53714 M 18540
120 Mike Smith 190 Fox St. 53713 M 18520
121 Alan Smith 123 Some St. 53711 M 18530
122 Brian Smith 190 Fox St. 53713 M 18500
123 Nancy Hagman 2205 Grand St. 53712 F 18500
124 Andre Dillard 1600 Ash St. 53714 M 18520
125 Jack Darrow 190 Fox St. 53713 M 18500
126 Vicki Berg 2205 Grand St. 53712 F 18540
127 Frank Marco 123 Some St. 53711 M 18500
128 Brenda Smithson 123 Some St. 53711 F 18530
129 Barry Thorpe 2205 Grand St. 53712 M 18500
130 Sheri Lytle 1600 Ash St. 53714 F 18520
131 Connie Hunter 1600 Ash St. 53714 F 18500
132 Jim Cramer 2205 Grand St. 53712 M 18540
133 Craig Kim 190 Fox St. 53713 M 18530
134 Jay Meyer 1600 Ash St. 53714 M 18500
135 John Reyes 2205 Grand St. 53712 M 18500
136 Curtis Strand 190 Fox St. 53713 M 18520
137 Fred Balmer 123 Some St. 53711 M 18500
138 Donna Gorman 2205 Grand St. 53712 F 18500
139 Janice Hall 190 Fox St. 53713 F 18530
140 Jenny Houseman 1600 Ash St. 53714 F 18540
141 Jane Linderman 2205 Grand St. 53712 F 18500
142 Sheila Moore 123 Some St. 53711 F 18520
143 Seth Olson 190 Fox St. 53713 M 18500
144 Kathy Roberts 2205 Grand St. 53712 F 18530
145 Laura Johnson 1600 Ash St. 53714 F 18520
146 Sharon Lee 2205 Grand St. 53712 F 18540
147 Jeff Sager 2205 Grand St. 53712 M 18530
148 Steve Stone 2205 Grand St. 53712 M 18520
149 Nick Mathis 190 Fox St. 53713 M 18530
150 Carrie Ramirez 2205 Grand St. 53712 F 18500
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill