Skip to content

Instantly share code, notes, and snippets.

@michaelminter
Created June 15, 2011 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelminter/1027134 to your computer and use it in GitHub Desktop.
Save michaelminter/1027134 to your computer and use it in GitHub Desktop.
Tinyized version of a scholarship calculator
<div id="schol_result">Please fill in your information and click CALCULATE</div>
<input type="text" id="act" />
<input type="text" id="gpa" />
<input type="submit" id="calculate-button" value="CALCULATE" />
<script type="text/javascript">
$(document).ready(function(){
$('#calculate-button').click(function() {
if (notEmpty($('#act')) && notEmpty($('#gpa'))) {
calc();
}
});
});
function calc() {
var desc = "";
var act = $('#act').val();
var nact = 0;
var ngpa = 0;
var gpa = $('#gpa').val();
var schol = new Array();
var amt = new Array(0,700,800,1000,1100,1200,1400,1600,1800,2000);
schol[4] = new Array(0, 1, 1, 3, 5, 6, 7, 8, 9);
schol[3] = new Array(0, 1, 1, 2, 5, 5, 7, 7, 8);
schol[2] = new Array(0, 1, 1, 2, 3, 3, 3, 6, 7);
schol[1] = new Array(0, 1, 1, 2, 2, 3, 3, 4, 5);
schol[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0);
switch(true) {
case(gpa < 3): ngpa=0;break;
case(gpa < 3.25): ngpa=1;break;
case(gpa < 3.5): ngpa=2;break;
case(gpa < 3.75): ngpa=3;break;
case(gpa >=3.75): ngpa=4;break;
default: ngpa=0;
}
switch(true) {
case(act < 22): nact=0;break;
case(act < 23): nact=1;break;
case(act < 24): nact=2;break;
case(act < 25): nact=3;break;
case(act < 26): nact=4;break;
case(act < 27): nact=5;break;
case(act < 28): nact=6;break;
case(act < 29): nact=7;break;
case(act >=29): nact=8;break;
default: nact=0;
}
//alert(schol[ngpa][nact]);
if (schol[ngpa][nact] == 0) {
$("#schol_result").html('<div style="font-size:10px;line-height:11px;">We offer general scholarships, talent awards in art, music, theatre, debate, athletics, and departmental scholarships. Call (877) 468-6378, <a href="mailto:go2esu@emporia.edu" target="_blank">email us</a> or <a href="http://www.emporia.edu/admiss" target="_blank">click here</a>.</div>');
} else {
var amount = amt[schol[ngpa][nact]];
$("#schol_result").html('Congratulations. Your test scores may qualify you for an ESU Hornet scholarship, worth $'+amount);
}
}
function notEmpty(object){
return (object.length > 0 ? true : false);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment