For our latest assignment, my teacher tasked us with creating a program to determine the highest and lowest marks among a group of up to 15 students. This means that we can input fewer than 15 students if needed. The user has to enter each student's name followed by their mark. Once all the names and marks are entered, the program should compare the marks to identify the highest and lowest ones.
CODE:
var Students = ["sn1", "sn2", "sn3", "sn4", "sn5", "sn6", "sn7", "sn8", "sn9", "sn10", "sn11", "sn12", "sn13", "sn14", "sn15"]; //array for student names
var Marks = ["sm1", "sm2", "sm3", "sm4", "sm5", "sm6", "sm7", "sm8", "sm9", "sm10", "sm11", "sm12", "sm13", "sm14", "sm15"]; //array for student marks
Students[0] = prompt("Enter Student 1's name.");
if(Students[0].length == 0) {
Marks[0] = null
} else {
Marks[0] = prompt("Enter Student 1's mark.");
//Code iteration repeated here multiple times for each student
}
console.log(Students[0] + " " + Marks[0]); //display the mark in console
//Further code for finding greatest and least marks is provided here.
PROBLEMS: 1. Currently, the program mistakenly identifies the first number as both the highest and lowest marks. For instance, entering 99 and then 100 will show 99 as the highest mark instead of 100. 2. Comparing numbers like 29 or 99 against 100 results in incorrect ranking due to how the comparison logic functions. 3. Negative numbers pose another challenge where -13 may incorrectly be labeled as the lowest when compared to -99. 4. Even when comparing 10 and 100 (including negative values), the program might wrongly prioritize 10 over the much larger value of 100.
It seems like you've put in considerable effort on troubleshooting these issues, especially considering this is your first experience with JavaScript. Should any further help be required before the Monday deadline, feel free to ask. Good luck!