0

I need Help with a program

Details: Design an algorithm that will produce a list of selected student names from a student file. Each input student record contains the students number, the students name, semester hours, and the age.
Your program is to read the student files and prepare a list of names of a full time student (12 credits) who are 30 years old or older, and are taking more than 20 semester hours. Place 3 asterisks after the students name. Print headings and column headings at the top of each page.

I have the arrays created so far but I could use help at the point where I need to pull the students based on specific details. (I think I need a while loop but I'm not to sure)

<TITLE> New Document </TITLE>

</HEAD>

<BODY>

<SCRIPT LANGUAGE="JavaScript">
<!--


var students = new Array("John", "Joe", "Sally", "Eliza", "Jim", "Bob", "Pete")

var credits = new Array(12,20,10,22,12,6)
var numbers = new Array(1456,1798,1389,2468,2314,6754,7800)
var age = new Array(30,20,50,19,22,32)
var studinfo = students.concat(numbers,credits,age,)

while (age[i] >= 30 )
{

}
//-->
</SCRIPT>


</BODY>
</HTML>
3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by jeffreylee
0

Good start, but I think you could use a better defined data structure. How about an array of objects, like so:

// Defines an array of objects:
StudentList = [ {}, {}, {} ];

StudentList[0].age = "29";
StudentList[0].semesterHours = 12;

StudentList[1].name = "Venom";
StudentList[1].age = "32";
StudentList[1].semesterHours = 14;

StudentList[2].name = "Hobgoblin";
StudentList[2].age = "34";
StudentList[2].semesterHours = 13;

alert( StudentList[1].name );

Then you can just loop over the StudentList array (StudentList.length) and filter it out based on criteria.

0

really worked in my project .....this code was perfectly correct as far as errors are concerned.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.