PROGRAM TO FIND & PRINT THE GRADE OF THE STUDENTS

<html>
<body>
<script type="text/javascript">

var names=new Array(10);
var scores=new Array(10);
var grades=new Array(10);

var choice,i,n,j;

choice="true";

var str="     ";

i=1;

while(choice=="true")
{
   names[i]=window.prompt("Enter name");
 
   scores[i]=parseInt(window.prompt("Enter score"));

   if (scores[i]>81) {
            grades[i]="A";
  }

 
   if (scores[i]>60 && scores[i]<81) {
            grades[i]="B";
  }


   if (scores[i]>40 && scores[i]<61){
            grades[i]="C";
  }

   if (scores[i]<41){
            grades[i]="D";
  }

choice=window.prompt("want to continue(true/false)");
i=i+1;
}

n=i;
for(j=1;j<n;j++)
{
  document.write(names[j]+str+scores[j]+str+grades[j]+"<br>");
}
</script>
</body>
</html>

No comments:

Post a Comment