Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
34 views3 pages

JS Laboratory 1

This document contains code for a web page that allows a user to convert a letter grade to a numerical grade value. The page has buttons to confirm or cancel the conversion. If confirmed, it prompts the user to enter a grade. Based on the entered grade, it calculates and alerts the user of the equivalent numerical value, ranging from 1.00 to 5.00. It also handles empty or invalid input.

Uploaded by

himikotoga1123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views3 pages

JS Laboratory 1

This document contains code for a web page that allows a user to convert a letter grade to a numerical grade value. The page has buttons to confirm or cancel the conversion. If confirmed, it prompts the user to enter a grade. Based on the entered grade, it calculates and alerts the user of the equivalent numerical value, ranging from 1.00 to 5.00. It also handles empty or invalid input.

Uploaded by

himikotoga1123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

<!

doctype html>

<html>

<head>

<title>Laboratory 1</title>

<style>

body {

margin:20px;

.all {

font-size:15px;

border-style: none;

border:1px;

text-align: center;

font-family: georgia;

button {

border-style:none;

background:#ff4d4d;

font-size: 15px;

font-family: georgia;

width: 10%;

border-radius: 2px;

color:white;

</style>

</head>

<body>

<div class="all">

<span>Convert my grade to numerical value</span><br>

<div>

<button onclick="convert()">Confirm</button>

<button onclick="closed()">Cancel</button>

</div>

</div>

<script>
function convert() {

var yes = confirm("Convert your grade to numerical value?");

if (yes) {

var value = prompt("Enter your grade");

if (value === "" || value === null) {

alert("The field is empty.")

else {

var grd = parseInt(value);

var grade;

if (grd >= 97 && grd <= 100) {

grade = 1.00;

else if (grd >= 94 && grd <= 96) {

grade = 1.25;

else if (grd >= 91 && grd <= 93) {

grade = 1.50;

else if (grd >= 88 && grd <= 90) {

grade = 1.75;

else if (grd >= 85 && grd <= 87) {

grade = 2.00;

else if (grd >= 82 && grd <= 84) {

grade = 2.25;

else if (grd >= 79 && grd <= 81) {

grade = 2.50;

}
else if (grd >= 76 && grd <= 78) {

grade = 2.75;

else if (grd == 75) {

grade = 3.00;

else {

grade = 5.00;

alert("Your grade numerical value is " + grade);

else {

window.close();

function closed() {

window.close();

</script>

</body>

</html>

You might also like