//Javascript
var html = "";
//Table headers
html += "<table><th style='width:25px'>No.</th>";
html += "<th style='width:100px'>Name</th>";
html += "<th style='width:100px'>Attendance</th>";
html += "<th style='width:100px'>Homework</th>";
html += "<th style='width:100px'>Midterm Test</th>";
html += "<th style='width:100px'>Final Exam</th>";
html += "<th style='width:100px'>Final Grade</th>";
html += "<th style='width:100px'>Letter Grade</th>";
//Setting the component weightage
do {
var weightAtt = parseFloat(prompt("Enter the weightage of attendance"));
while (weightAtt <= 0 || weightAtt >= 1 || isNaN(weightAtt)) {
alert("The weightage of attendance must a positive number less than 1");
var weightAtt = parseFloat(prompt("Enter the weightage of attendance"));
}
var weightHw = parseFloat(prompt("Enter the weightage of homework"));
/* looping forever on playwright
while (weightHw <= 0 || weightHw >= 1 || isNaN(weightHw)) {
alert("The weightage of homework must a positive number less than 1");
var weighthw = parseFloat(prompt("Enter the weightage of homework"));
}
var weightMdt = parseFloat(prompt("Enter the weightage of midterm test"));
while (weightMdt <= 0 || weightMdt >= 1 || isNaN(weightMdt)) {
alert("The weightage of midterm test must a positive number less than 1");
var weightMdt = parseFloat(prompt("Enter the weightage of midterm test"));
}
var weightFx = parseFloat(prompt("Enter the weightage of final exam"));
while (weightFx <= 0 || weightFx >= 1 || isNaN(weightFx)) {
alert("The weightage of final exam must a positive number less than 1");
var weightFx = parseFloat(prompt("Enter the weightage of final exam"));
}
if ([weightAtt + weightHw + weightMdt + weightFx] != 1) {
alert("The total weightage of all components must be equals to 1!");
}
}
while ([weightAtt + weightHw + weightMdt + weightFx] !=...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.