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>

Recommended Answers

All 3 Replies

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.

I have solved this Thank you

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.