function calculate() {
// Declare a variable to store the total score of EST or equivalent var total; //total est1 or equivalent var total2; // total est2 or equivalent var num5; //total GPA
//ACT to SAT and est Tables var actToEsMathtMapping = { 36: 800, 35: 780, 34: 760, 33: 740, 32: 720, 31: 710, 30: 700, 29: 680, 28: 660, 27: 640, 26: 610, 25: 590, 24: 580, 23: 560, 22: 540, 21: 530, 20: 520, 19: 510, 18: 500, 17: 470, 16: 430, 15: 400, 14: 360, 13: 330, 12: 310, 11: 280, 10: 260 };
var actToEsEnglishMapping = { 72: 790, 71: 770, 70: 750, 69: 740, 68: 730, 67: 720, 66: 710, 65: 700, 64: 700, 63: 690, 62: 680, 61: 680, 60: 670, 59: 660, 58: 660, 57: 650, 56: 640, 55: 640, 54: 630, 53: 630, 52: 620, 51: 610, 50: 610, 49: 600, 48: 590, 47: 580, 46: 580, 45: 570, 44: 560, 43: 550, 42: 540, 41: 540, 40: 520, 39: 520, 38: 510, 37: 500, 36: 500, 35: 490, 34: 480, 33: 470, 32: 460, 31: 450, 30: 440, 29: 430, 28: 420, 27: 410, 26: 400, 25: 390, 24: 380, 23: 370, 22: 360, 21: 350, 20: 340, 19: 330, 18: 320, 17: 310, 16: 300, 15: 290, 14: 280 };
//remove previous scores var answ = document.getElementById("answer2_div");
document.getElementById("answer").innerHTML = ""; answ.style.display="none";
var matching = document.querySelector('input[name="choice"]:checked').value; if(matching == "withoutsupermatching"){ // rest any previous errors // Remove red backgroundColor from input fields document.getElementById("est_Math_scpre").style.backgroundColor = ""; document.getElementById("est_English_score").style.backgroundColor = ""; document.getElementById("subjecttestfirstsubjectinput").style.backgroundColor = ""; document.getElementById("subjecttest2ndsubjectinput").style.backgroundColor = ""; document.getElementById("ACT_writing_Score").style.backgroundColor = ""; document.getElementById("ACT_Reading_Score").style.backgroundColor = "";
// Get the input values from the HTML elements var num1 = Number(document.getElementById("est_Math_scpre").value); var num2 = Number(document.getElementById("est_English_score").value); var numACTWriting = Number(document.getElementById("ACT_writing_Score").value); var numACTReading = Number(document.getElementById("ACT_Reading_Score").value); var num3 = Number(document.getElementById("subjecttestfirstsubjectinput").value); var num4 = Number(document.getElementById("subjecttest2ndsubjectinput").value);
// Get the selected option from the first dropdown menu var test = document.getElementById("test").value;
// Convert the scores based on the test option if (test == "EST") { // Check if the scores are within range if (num1 < 200 || num1 > 800) { alert("Please enter valid scores for EST Math. The scores should be between 200 and 800."); document.getElementById("est_Math_scpre").style.backgroundColor = "#ffcccc"; document.getElementById("est_Math_scpre").focus(); return; } if (num2 < 200 || num2 > 800) { alert("Please enter valid scores for EST English. The scores should be between 200 and 800."); document.getElementById("est_English_score").style.backgroundColor = "#ffcccc"; document.getElementById("est_English_score").focus(); return; }
// No conversion needed, just add the scores total = num1 + num2; } else if (test == "ACT") { // Check if the scores are within range if (num1 < 10 || num1 > 36) { alert("Please enter valid scores for ACT Math. The scores should be between 10 and 36."); document.getElementById("est_Math_scpre").style.backgroundColor = "#ffcccc"; document.getElementById("est_Math_scpre").focus(); return; } if (numACTWriting < 10 || numACTWriting > 36) { alert("Please enter valid scores for ACT Writing English Score. The scores should be between 10 and 36."); document.getElementById("ACT_writing Score").style.backgroundColor = "#ffcccc"; document.getElementById("ACT_writing_Score").focus(); return; } if (numACTReading < 10 || numACTReading > 36) { alert("Please enter valid scores for ACT Reading English score. The scores should be between 10 and 36."); document.getElementById("ACT_Reading_Score").style.backgroundColor = "#ffcccc"; document.getElementById("ACT_Reading_Score").focus(); return; }
var ACTtoalEngilh= numACTWriting + numACTReading; var engilshscoreafterconvertingtoEST = actToEsEnglishMapping[ACTtoalEngilh]; var mathscoreafterconvertiontoest = actToEsMathtMapping[num1];
total = engilshscoreafterconvertingtoEST + mathscoreafterconvertiontoest;
} else if (test == "SAT") {
// Check if the scores are within range if (num1 < 200 || num1 > 800) { alert("Please enter valid scores for SAT Math. The scores should be between 200 and 800."); document.getElementById("est_Math_scpre").style.backgroundColor = "#ffcccc"; document.getElementById("est_Math_scpre").focus(); return; } if (num2 < 200 || num2 > 800) { alert("Please enter valid scores for SAT English. The scores should be between 200 and 800."); document.getElementById("est_English_score").style.backgroundColor = "#ffcccc"; document.getElementById("est_English_score").focus(); return; } // No conversion needed, just add the scores total = num1 + num2; } else { alert("Please select a test option"); return; }
// Get the selected option from the second dropdown menu var subject = document.getElementById("subject").value;
// Convert the scores based on the subject option if (subject == "EST2") { // Check if the scores are within range if (num3 < 200 || num3 > 800) { alert("Please enter valid scores for EST 2 Subject 1. The scores should be between 200 and 800."); document.getElementById("subjecttestfirstsubjectinput").style.backgroundColor = "#ffcccc"; document.getElementById("subjecttestfirstsubjectinput").focus(); return; } if (num4 < 200 || num4 > 800) { alert("Please enter valid scores for EST 2 Subject 2. The scores should be between 200 and 800."); document.getElementById("subjecttest2ndsubjectinput").style.backgroundColor = "#ffcccc"; document.getElementById("subjecttest2ndsubjectinput").focus(); return; }
// No conversion needed, just add the scores total2 = num3 + num4;
} else if (subject == "ACT2") { // Check if the scores are within range if (num3 < 10 || num3 > 36) { alert("Please enter valid scores for ACT 2 Subject 1. The scores should be between 10 and 36."); document.getElementById("subjecttestfirstsubjectinput").style.backgroundColor = "#ffcccc"; document.getElementById("subjecttestfirstsubjectinput").focus(); return; } if (num4 < 10 || num4 > 36) { alert("Please enter valid scores for ACT 2 Subject 2. The scores should be between 200 and 800."); document.getElementById("subjecttest2ndsubjectinput").style.backgroundColor = "#ffcccc"; document.getElementById("subjecttest2ndsubjectinput").focus(); return; }
total2 = actToEsMathtMapping[num3] + actToEsMathtMapping[num4];
} else if (subject == "None") { // Assign zero to both scores total2 = 0; num3 = 0; num4 = 0;
} else { alert("Please select a subject option"); return; } } else if(matching =="withsupermatching"){ // rest any previous errors // Remove red backgroundColor from input fields document.getElementById("est_Math_scpre_withMatching").style.backgroundColor = ""; document.getElementById("English_scpre_withMatching").style.backgroundColor = ""; document.getElementById("subjecttestfirstsubjectinput_withMatching").style.backgroundColor = ""; document.getElementById("subjecttest2ndsubjectinput_withMatching").style.backgroundColor = ""; document.getElementById("English2_scpre_withMatching").style.backgroundColor = "";
// Get the input values from the HTML elements var num1 = Number(document.getElementById("est_Math_scpre_withMatching").value); var num2 = Number(document.getElementById("English_scpre_withMatching").value); var numACTWriting = num2; var numACTReading = Number(document.getElementById("English2_scpre_withMatching").value); var num3 = Number(document.getElementById("subjecttestfirstsubjectinput_withMatching").value); var num4 = Number(document.getElementById("subjecttest2ndsubjectinput_withMatching").value);
// Get the selected option from the Math test dropdown menu var Mathtest = document.getElementById("Mathtest").value;
// Convert the scores based on the test option for Math if (Mathtest == "EST") { // Check if the scores are within range if (num1 < 200 || num1 > 800) { alert("Please enter valid scores for EST Math. The scores should be between 200 and 800."); document.getElementById("est_Math_scpre_withMatching").style.backgroundColor = "#ffcccc"; document.getElementById("est_Math_scpre_withMatching").focus(); return; } total = num1; } else if (Mathtest == "ACT") { // Check if the scores are within range if (num1 < 10 || num1 > 36) { alert("Please enter valid scores for ACT Math. The scores should be between 10 and 36."); document.getElementById("est_Math_scpre_withMatching").style.backgroundColor = "#ffcccc"; document.getElementById("est_Math_scpre_withMatching").focus(); return; }
total = actToEsMathtMapping[num1];
} else if (Mathtest == "SAT") {
// Check if the scores are within range if (num1 < 200 || num1 > 800) { alert("Please enter valid scores for SAT Math. The scores should be between 200 and 800."); document.getElementById("est_Math_scpre_withMatching").style.backgroundColor = "#ffcccc"; document.getElementById("est_Math_scpre_withMatching").focus(); return; } total = num1; } else { alert("Please select a Math test option"); return; }
// Get the selected option from the English test dropdown menu var Englishtest = document.getElementById("Englishtest").value;
// Convert the scores based on the test option for Math if (Englishtest == "EST") { // Check if the scores are within range if (num2 < 200 || num2 > 800) { alert("Please enter valid scores for EST English. The scores should be between 200 and 800."); document.getElementById("English_scpre_withMatching").style.backgroundColor = "#ffcccc"; document.getElementById("English_scpre_withMatching").focus(); return; } total += num2; } else if (Englishtest == "ACT") { if (numACTWriting < 10 || numACTWriting > 36) { alert("Please enter valid scores for ACT Writing. The scores should be between 10 and 36."); document.getElementById("English_scpre_withMatching").style.backgroundColor = "#ffcccc"; document.getElementById("English_scpre_withMatching").focus(); return; } if (numACTReading < 10 || numACTReading > 36) { alert("Please enter valid scores for ACT Reading score. The scores should be between 10 and 36."); document.getElementById("English2_scpre_withMatching").style.backgroundColor = "#ffcccc"; document.getElementById("English2_scpre_withMatching").focus(); return; }
var ACTtoalEngilh= numACTWriting + numACTReading; var engilshscoreafterconvertingtoEST = actToEsEnglishMapping[ACTtoalEngilh];
total += engilshscoreafterconvertingtoEST;
} else if (Englishtest == "SAT") {
// Check if the scores are within range if (num2 < 200 || num2 > 800) { alert("Please enter valid scores for SAT English. The scores should be between 200 and 800."); document.getElementById("English_scpre_withMatching").style.backgroundColor = "#ffcccc"; document.getElementById("English_scpre_withMatching").focus(); return; } total += num2; } else { alert("Please select English test option"); return; }
//est 2 or ACT 2 calculations var subject1test = document.getElementById("subject1_withmatching").value;
// subject 1 if (subject1test == "EST2") { // Check if the scores are within range if (num3 < 200 || num3 > 800) { alert("Please enter valid scores for Subject 1 - est 2. The scores should be between 200 and 800."); document.getElementById("subjecttestfirstsubjectinput_withMatching").style.backgroundColor = "#ffcccc"; document.getElementById("subjecttestfirstsubjectinput_withMatching").focus(); return; } total2 = num3; } else if (subject1test == "ACT2") { // Check if the scores are within range if (num3 < 10 || num3 > 36) { alert("Please enter valid scores for Subject 1 - ACT2. The scores should be between 10 and 36."); document.getElementById("subjecttestfirstsubjectinput_withMatching").style.backgroundColor = "#ffcccc"; document.getElementById("subjecttestfirstsubjectinput_withMatching").focus(); return; } total2 = actToEsMathtMapping[num3] ; } else if (subject1test == "None") { // Assign zero to both scores total2 = 0; num3 = 0; }
// subject 2 var subject2test = document.getElementById("subject2_withmatching").value;
if (subject2test == "EST2") { // Check if the scores are within range if (num4 < 200 || num4 > 800) { alert("Please enter valid scores for Subject 2 - est 2. The scores should be between 200 and 800."); document.getElementById("subjecttest2ndsubjectinput_withMatching").style.backgroundColor = "#ffcccc"; document.getElementById("subjecttest2ndsubjectinput_withMatching").focus(); return; } total2 += num4; } else if (subject2test == "ACT2") { // Check if the scores are within range if (num4 < 10 || num4 > 36) { alert("Please enter valid scores for ACT 2 Subject 1. The scores should be between 10 and 36."); document.getElementById("subjecttest2ndsubjectinput_withMatching").style.backgroundColor = "#ffcccc"; document.getElementById("subjecttest2ndsubjectinput_withMatching").focus(); return; } total2 += actToEsMathtMapping[num4] } else if (subject2test == "None") { // Assign zero to both scores total2 = 0; num4 = 0; }
}
console.log("total 1 ="+total+" total 2="+total2);
// get GPA score var GPAinputtype = document.getElementById("choice").value; if(GPAinputtype =="gpa"){ if(validateGPA()){ num5 = Number(document.getElementById("gpa").value); } else { return; }
} else if ( GPAinputtype =="subject" ){ if(validateSubjects()){ // Initialize the sum of scores var sum = 0; // Get the input elements and their values var inputs = document.getElementsByClassName("subject"); var values = []; for (var i = 0; i < inputs.length; i++) { values.push(inputs[i].value); sum += Number(values[i]); } num5 = (sum/800)*40; } else { return ; } } console.log("GPA ="+num5); console.log("total score for 1 is: "+ total +" total score for 2 is: "+ total2 +" ."); // Get the selected option from the third dropdown menu var option = document.getElementById("option").value; // Declare a variable to store the Score of the studnet var finalscoreforuniversity; var textwithscore ; // Assign the final score based on the option and the condition if (option == "Option 1") { if (total >= 1090) { if(total2 >= 900){
finalscoreforuniversity = (total/1600)*75+((total2)*15/1600) + num5 ;
}else if(total2 < 900){ finalscoreforuniversity = (total/1600)*75 + num5 ; } } else if(total >= 800){ if(total2 >= 900){
finalscoreforuniversity = (total/1600)*60+((total2)*15/1600) + num5 ;
}else if(total2 < 900){ finalscoreforuniversity = (total/1600)*60 + num5 ; } } else { alert("for Private Egyptian Univesities your est, ACT or SAT must exced 800"); return; } textwithscore = " for Egyptian Private Univesities"; } else if (option == "Option 2") { if (total >= 1090) {
if(total2 >= 1100){
finalscoreforuniversity = ((total/1600)*69) + (total2*15/1600) + num5;
}else if(total2 < 1100){ finalscoreforuniversity = ((total/1600)*69) + num5; } console.log("final univesity if more 1090 is:" + finalscoreforuniversity); } else if (total >=1050) {
if(total2 >= 1100){
finalscoreforuniversity = (total/1600)*60+(total2*15/1600) + num5;
}else if(total2 < 1100){ finalscoreforuniversity = ((total/1600)*60) + num5; } console.log("final univesity if less 1090 is:" + finalscoreforuniversity); } else{ alert("for Governmental univesities your est, ACT or SAT must exced 1050"); return; } textwithscore= "for Egyptian Governmental Univesities'"; } else { alert("Please select an option for the type of university you applying for even Private university جامعة خاصة or Governmental univesity جامعة حكومية"); return; } console.log("total score for 1 is: "+ total +" total score for 2 is: "+ total2 +" ."); // Round the final score to two decimal places finalscoreforuniversity = Math.round(finalscoreforuniversity * 100) / 100; // Display the result in the HTML element with id="answer" and "answer2" document.getElementById("answer").innerHTML = "Your scores is equivalent to " + finalscoreforuniversity +"% "+ textwithscore +" your GPA percentage is: "+ num5; document.getElementById("answer").style.color = "#2196F3"; document.getElementById("answer").style.fontWeight = "bold"; answ.style.display = "block"; /* answ.textContent = "Your scores is equivalent to " + finalscoreforuniversity +"% "+ textwithscore +" your GPA percentage is: "+ num5+"%"; */ answ.style.color = "#2196F3"; document.getElementById("GPA-reuslt").innerHTML = num5+"%"; document.getElementById("Result").innerHTML = finalscoreforuniversity +"% "; document.getElementById("Result-Type").innerHTML = textwithscore; document.getElementById("answer2_div").scrollIntoView({behavior: "smooth", block: "center"}); } // Define a new function to show or hide the inputs for subject test scores function showHide() { // Get the selected option from the second dropdown menu var subject = document.getElementById("subject").value; // Show or hide the inputs based on the subject option if (subject == "EST2") { // Show the text boxes for subject test scores document.getElementById("subjecttestfirstsubjectlabel").style.display = "block"; document.getElementById("subjecttestfirstsubjectinput").style.display = "block"; document.getElementById("subjecttest2ndsubjectlabel").style.display = "block"; document.getElementById("subjecttest2ndsubjectinput").style.display = "block"; document.getElementById("Subjecttest-container").style.display = "block"; document.getElementById("subjecttestfirstsubjectlabel").innerHTML = "EST 2 Subject 1 score"; document.getElementById("subjecttest2ndsubjectlabel").innerHTML = "EST 2 Subject 2 score"; } else if (subject == "ACT2") { // Show the text boxes for subject test scores document.getElementById("subjecttestfirstsubjectlabel").style.display = "block"; document.getElementById("subjecttestfirstsubjectinput").style.display = "block"; document.getElementById("subjecttest2ndsubjectlabel").style.display = "block"; document.getElementById("subjecttest2ndsubjectinput").style.display = "block"; document.getElementById("Subjecttest-container").style.display = "block"; document.getElementById("subjecttestfirstsubjectlabel").innerHTML = "ACT 2 Subject 1 score"; document.getElementById("subjecttest2ndsubjectlabel").innerHTML = "ACT 2 Subject 2 score"; } else if (subject == "None") { // Hide the text boxes for subject test scores document.getElementById("subjecttestfirstsubjectlabel").style.display = "none"; document.getElementById("subjecttestfirstsubjectinput").style.display = "none"; document.getElementById("subjecttest2ndsubjectlabel").style.display = "none"; document.getElementById("subjecttest2ndsubjectinput").style.display = "none"; document.getElementById("Subjecttest-container").style.display = "none"; } } function showHidetesttype(){ // Get the selected option from the first dropdown menu var testtype = document.getElementById("test").value; // Show or hide the inputs based on the subject option if (testtype == "EST" || testtype == "SAT") { // Show the text boxes for SAT or EST test scores document.getElementById("labelmathscore").style.display = "block"; document.getElementById("est_Math_scpre").style.display = "block"; document.getElementById("lableEnglishScore").style.display = "block"; document.getElementById("est_English_score").style.display = "block"; document.getElementById("ESTorSAT-container").style.display = "block"; // Hide the text boxes for ACT test scores document.getElementById("labelACTwriting").style.display = "none"; document.getElementById("ACT_writing_Score").style.display = "none"; document.getElementById("labelACTreading").style.display = "none"; document.getElementById("ACT_Reading_Score").style.display = "none"; document.getElementById("ACTEnglish-container").style.display="none"; } else if (testtype == "ACT") { // Hide the text boxes for SAT or EST test scores except the Math document.getElementById("labelmathscore").style.display = "block"; document.getElementById("est_Math_scpre").style.display = "block"; document.getElementById("lableEnglishScore").style.display = "none"; document.getElementById("est_English_score").style.display = "none"; // Show the text boxes for ACT test scores document.getElementById("labelACTwriting").style.display = "block"; document.getElementById("ACT_writing_Score").style.display = "block"; document.getElementById("labelACTreading").style.display = "block"; document.getElementById("ACT_Reading_Score").style.display = "block"; document.getElementById("ACTEnglish-container").style.display="block"; document.getElementById("ESTorSAT-container").style.display = "block"; } } // A function to validate the GPA input function validateGPA() { // Get the input element and its value var input = document.getElementById("gpa"); var value = input.value; // Get the error message element var error = document.getElementById("gpa-error"); // Check if the value is a valid number between 0 and 4 if (isNaN(value) || value < 0 || value > 40) { // Display an error message error.innerHTML = "Please enter a valid GPA Score must be between 0% and 40%."; } else { // Clear the error message error.innerHTML = ""; return true; } }
// A function to validate the subject inputs function validateSubjects() { // Get the input elements and their values var inputs = document.getElementsByClassName("subject"); var values = []; for (var i = 0; i < inputs.length; i++) { values.push(inputs[i].value); } // Get the error message elements var errors = document.getElementsByClassName("subject-error"); // Check if each value is a valid number between 0 and 100 for (var i = 0; i < values.length; i++) { if (isNaN(values[i]) || values[i] < 0 || values[i] > 100) { // Display an error message errors[i].innerHTML = "Please enter a valid score between 0 and 100."; return false; } else { // Clear the error message errors[i].innerHTML = ""; } }
return true ; }
// A function to show or hide the GPA or subject inputs based on the user's choice function showInput(choice) { // Get the GPA and subject input elements var gpaInput = document.getElementById("gpa-input"); var subjectInput = document.getElementById("subject-input");
// Show or hide the input elements based on the choice parameter if (choice == "gpa") { gpaInput.style.display = "block"; subjectInput.style.display = "none"; } else if (choice == "subject") { gpaInput.style.display = "none"; subjectInput.style.display = "block"; } else { gpaInput.style.display = "none"; subjectInput.style.display = "none";; } }
//withmatching functions
function showDiv_Matching(){
var choice = document.querySelector('input[name="choice"]:checked').value; if (choice == "withoutsupermatching") { document.getElementById("withoutmatchingdiv").style.display = "block"; document.getElementById("withmatchingdiv").style.display = "none"; } else if (choice == "withsupermatching") { document.getElementById("withoutmatchingdiv").style.display = "none"; document.getElementById("withmatchingdiv").style.display = "block"; } }
function showHidetesttypeEnglish(){ // Get the selected option from the first dropdown menu var testtype = document.getElementById("Englishtest").value;
// Show or hide the inputs based on the subject option if (testtype == "EST" || testtype == "SAT") {
// Show the text boxes for SAT or EST test scores document.getElementById("English_scpre_withMatching").style.display = "inline"; document.getElementById("English_scpre_withMatching").placeholder ="English Score";
// Hide the text boxes for ACT test scores document.getElementById("English2_scpre_withMatching").style.display = "none"; }else if (testtype == "ACT"){ // Show the text boxes for ACT test scores document.getElementById("English_scpre_withMatching").style.display = "inline"; document.getElementById("English_scpre_withMatching").placeholder ="Writing Score"; document.getElementById("English2_scpre_withMatching").style.display = "inline"; } }
function showhideWithmatchingSubjecttest(){ var subject1test = document.getElementById("subject1_withmatching").value; if(subject1test == "EST2"){ document.getElementById("subjecttestfirstsubjectinput_withMatching").style.display = "inline"; document.getElementById("second_subject_div").style.display = "inline"; } else if (subject1test == "ACT2"){ document.getElementById("subjecttestfirstsubjectinput_withMatching").style.display ="inline"; document.getElementById("second_subject_div").style.display = "inline"; } else { document.getElementById("subjecttestfirstsubjectinput_withMatching").style.display ="none"; document.getElementById("second_subject_div").style.display = "none"; }
var subject2test = document.getElementById("subject2_withmatching").value; if(subject2test == "EST2"){ document.getElementById("subjecttest2ndsubjectinput_withMatching").style.display ="inline"; } else if (subject2test == "ACT2"){ document.getElementById("subjecttest2ndsubjectinput_withMatching").style.display ="inline"; } else { document.getElementById("subjecttest2ndsubjectinput_withMatching").style.display ="none"; }
}
Scholastic test scores:
School GPA scores:
%
Applying to:
Equivalent score result
| GPA: | |
| Scores Equivalent to: |