Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) Develop an algorithm and write the html and JavaScript that displays a web pa

ID: 3730177 • Letter: 1

Question

1) Develop an algorithm and write the html and JavaScript that displays a web page titled "Grade Calculator". This code will allow a student to enter a grade, in integer form (like 85 or 72), through the prompt statement or a html form. Check the entered value to make sure it is between 0 and 100 inclusive. If it is outside this range print an error message in an Alert box and end the program. If the entered value is within the range of 0 - 100 inclusive then use a series of If/Else statements to classify the grade according to the following range: 0 to 49 = Poor; 50 to 64 = Below Average; 65 to 79= Average; 80 to 89 = Above Average; and 90 or higher as Exceptional. Display the grade entered and the classification in an Alert box. For Example a grade of 55 would be classified as 55 is Below Average while a grade of 95 would be classified as 95 is Exceptional.

2) Develop an algorithm and write the html and JavaScript that displays a web page that is titled "Math Calculator ". Your code should allow the user to enter two numbers through two prompt boxes- then again, through a prompt box, ask the user if they want to add, subtract, multiply, or divide the two numbers. Prompt the user to enter a 1 to add, 2 to subtract, 3 to multiply, or 4 to divide. If a number other 1, 2, 3, or 4 is entered then print an error message (either in an Alert box or in the document window) and exit the program. If a correct number is entered print the two numbers and the arithmetic result in the document window. Then ask the user if they want to perform another set of arithmetic - if the user responds Y or y (for yes ) then loop back up, allow the user to enter two new numbers, and a new operation. Continue till the user enters a character other than Y or y to indicate that they do not want to any more arithmetic calculations to be performed. All of the calculations should be displayed in the document window. And if the user enters a number other 1, 2, 3, or 4 - display an error in an Alert box and give the user 2 more chances to enter a correct number ( 1 through 4). After the user enters the third incorrect response, then exit the program (this requires a loop).

Explanation / Answer

Following is the java Script Code:

1)

<html>

<head>

<script type="text/javascript">

var n = window.prompt("Enter Number");

if(n<=100 || n>=0){

if(n>=0 || n<=49){

window.alert("Grade"+ n + " is " + "Poor.");

}else if(n>=50 || n<=64){

window.alert("Grade"+ n + " is " + "Below Average.");

}else if(n>=65 || n<=79){

window.alert("Grade"+ n + " is " + "Average.");

}else if(n>=80 || n<=89){

window.alert("Grade"+ n + " is " + "Above Average.");

}else{

window.alert("Grade"+ n + " is " + "higher as Exceptional.");

}

}else{

window.alert("Enter Number between 0-100");

}

</script>

<title>Grade Calculator</title>

</head>

<body>

</body>

</html>

2)

<html>

<head>

<script type="text/javascript">

var n1 = window.prompt("Enter Number");

var n2 = window.prompt("Enter Number");

var ch;

function arithmetic(){

var n = window.prompt("1.Addition 2.Subtraction 3.Multiply 4.Division" );

if(n == 1 || n == 2 || n == 3 || n == 4){

var n1 = window.prompt("Number 1: ");

var n2 = window.prompt(" Number 2: ");

window.alert("Number 1: " + n1 + " Number 2: " + n2);

document.write();

if(n == 1){

var sum = n1+n2;

window.prompt("Number 1: " + n1 + " Number 2: " + n2 + " Addition is: " + sum);

}else if(n==2){

var sub = n1-n2;

window.prompt("Number 1: " + n1 + " Number 2: " + n2 + " Subtraction is: " + sub);

}else if(n==3){

var mul = n1*n2

window.prompt("Number 1: " + n1 + " Number 2: " + n2 + " Multiply is: " + mul);

}else{

var div = n1/n2;

window.prompt("Number 1: " + n1 + " Number 2: " + n2 + " Division is: " + div);

}

}

else{

window.alert("Wrong Choice.");

}

window.prompt("Enter Y or y to continue: " + ch);

}

arithmetic();

if(ch == "Y" || ch== "y"){

window.alert(n);

arithmetic();

}else{

break();

}

</script>

<title>Grade Calculator</title>

</head>

<body>

</body>

</html>