# Javascript Hw Problem



## epicfail (May 12, 2010)

K i have to write a function called QualityPoints that inputs a students average and returns 4 if a students average is 90-100, 3 if its 80-89 and so on. down to 0 if the average is lower than 60.
Incorporate the function into a script that reads a value from the user display the result of the function in the browsers status bar



```
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<Script>
function QualityPoints(){

   var c = 0
{
if ( c>=90 && c<=100 ) 
showStatus(4);
else if ( c>=80 && c <90 ) 
showStatus(3);
else if ( c>=70 && c< 80 )
showStatus(2);
else if ( c>=60 && c<70)
showStatus(1);
else
showStatus(0);
 }
</script>
</head>

<body>
<table border=1 cellpadding="5">
<tr><td>
<FORM NAME="convert">
<INPUT TYPE="TEXT" NAME="QualityPoint" VALUE="0" SIZE=4 MAXLENGTH=6
  <font size="+2">Enter Grade</font>

<INPUT TYPE="BUTTON" VALUE="Enter Grade" onClick="QualityPoints();">

</FORM>
</table>

</body>
</html>
```

is what i have it says there is a object expected at line 31


----------



## Easy Rhino (May 12, 2010)

you either have an extra opening bracket or you are missing a closing bracket somewhere.


----------



## epicfail (May 12, 2010)

Easy Rhino said:


> you either have an extra opening bracket or you are missing a closing bracket somewhere.



thansk just started over though and did it with more functions than just one



```
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 
<html> 
    <head> 
    <script type="text/javascript"> 
 
 
function qualityPoints() 
  {                                        										
if ( points>=90 && points<=100 ) 
points=4;
else if ( points>=80 && points <90 ) 
points=3;
else if ( points>=70 && points< 80 )
points=2;
else if ( points>=60 && points<70)
points=1;
else
points=0;
 }
            function PrintExplanation() 
            { 
               alert(" Please Enter your Grade And The Semester it was in. \n\nGrade points are: \n\n4 for A \n3 for B \n2 for C \n1 for D \nand 0 for F"); 
            } 
 
            function GetValidInput(promptString, sentinel) 
            { 
               var input 
 
                input = parseInt( prompt( promptString)); 
                if(isNaN(input)){ 
                        alert("Not a valid number"); 
                        input = GetValidInput(promptString, sentinel) 
                } 
                                         
                return input; 
            } 
             
 
 
            function GenerateGradeReport (semester,  totalPoints) 
            { 
               var GPA = CalculateGPA(totalQuality); 
               document.write("Your Grade Point Average For  ".fontsize(4) + semester.fontsize(4) +  "<br/>is GPA : " + GPA); 
            } 
 
 
            function CalculateGPA(totalQuality) 
            { 
               return totalQuality; 
            
            } 
        </script> 
    </head> 
    <body> 
        <h1>GPA Calculator</h1> 
        <script type="text/javascript"> 

            var totalQuality = 0; 
                                var grades=0; 
                                 
            PrintExplanation(); 
            var semester = prompt("Please enter your semester: ","example: Spring 2009"); 
 
             
            
 
                                        points = GetValidInput("Whats your Average In This Class","0"); 
                                        
qualityPoints(); 
                                     
                                        totalQuality =  points; 
 
            
             
            GenerateGradeReport(semester, totalQuality); 
            
        </script> 
    </body> 
 
 
</html>
```

it works now so all good.


----------



## Easy Rhino (May 12, 2010)

epicfail said:


> thansk just started over though and did it with more functions than just one
> 
> 
> 
> ...



ha good. i didnt see you said that it worked after i spent a few minutes going through your new code looking for problems hehe.


----------



## epicfail (May 12, 2010)

Easy Rhino said:


> ha good. i didnt see you said that it worked after i spent a few minutes going through your new code looking for problems hehe.



k oops my bad what exactly do you switch around to post it in the status bar instead ive been trying to find it but cant for some stupid reason.

fixed


----------

