I need help in javascript! Design and implement a JavaScript program to accompli
ID: 3789894 • Letter: I
Question
I need help in javascript!
Design and implement a JavaScript program to accomplish the following:
1. Iterate and accept N test scores and N student names (where 10 <= N <= 20).
2. Compute the sum and average of the scores (display these values).
3. Implement a function that determines the highest score (display this value).
4. Implement a function that determines the lowest score (display this value).
5. Implement a function that determines the letter grade of each score:
90-100 (A); 80 - 89 (b); 70 - 79 (C); 60 - 69 (D); 0 - 59 (F)
6. Display a table showing each student's name, score, and letter grade.
7. The highest and lowest scores should be highlighted with different colors.
Explanation / Answer
<HTML>
<HEAD>
<TITLE> Max Min Sum Avg</TITLE>
</HEAD>
<BODY>
<p>
<script type="text/javascript">
var i,n;
var max=0;
var min=0;
var sum=0;
var avg=0;
n=parseInt(prompt(“Enter array size”));
if(n>=10 && n<=20)
{
var scores=new Array(n);
var names=new Array(n);
for(i=0;i<n;i++)
{
scores[i]=parseInt(prompt(“Enter numbers”));
names[i]=prompt("enter name");
}
// finding Sum of Array Numbers……..
sum=0;
for(i=0;i<n;i++)
{
sum=sum+scores[i];
}
// finding Average……..
avg=sum/n;
// finding Maximum……..
max=scores[0];
for(i=1;i<n;i++)
{
if(max<scores[i])
max=scores[i];
}
// finding Minimum……..
min=scores[0];
for(i=1;i<n;i++)
{
if(min>scores[i])
min=scores[i];
}
document.write(“<br><font color="red”>"+”Maximum= “+max+”<br></font”);
document.write(“<font color="yellow">+"Minimum Number= “+min+”<br>”);
document.write(“Sum of Array Numbers= “+sum+”<br>”);
document.write(“Average= “+avg+”<br>”);
document.write(“Array Elements : – “);
for(i=0;i<n;i++)
{
document.write(scores[i]+” ,“+names[i]);
}
}
</script>
</BODY>
</HTML>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.