xxxxxxxxxx
240
//CONSTANTS
var FLL_CHALLENGE_COST = 350;
var FTC_COST = 750;
var FRC_COST = 1250;
var FLL_EXPLORE_CAMP_COST = 250;
var FLL_CHALLENGE_CAMP_COST = 300;
var HOUSTON24_COST = 1050;
var FLL_CHAL_PROGRAM_NAME = "4th-6th Grade - FLL Challenge Fall Teams";
var FLL_EXP_PROGRAM_NAME = "1st-3rd Grade - FLL Explore Spring Teams";
var FTC_PROGRAM_NAME = "7th-12th Grade - Fall Robotics";
var FTCFRC_PROGRAM_NAME = "7th-12th Grade - Fall Robotics w/ FRC Team Add-On";
var INCOME_SCALE = [
[30660, 81760],
[38730, 103280],
[46800, 124800],
[54870, 146320],
[62940, 167840],
[71010, 189360],
[79080, 210880],
];
var famSizeSel;
var incomeSel;
var progSel;
var calBut;
function setup() {
createCanvas(700, 450);
//createCanvas(windowWidth, windowHeight);
createInputs();
writeMainText();
}
function draw() {
}
function createInputs() {
famSizeSel = createSelect();
famSizeSel.position(width / 3, height * 0.336);
famSizeSel.option("2");
famSizeSel.option("3");
famSizeSel.option("4");
famSizeSel.option("5");
famSizeSel.option("6");
famSizeSel.option("7");
famSizeSel.option("8");
incomeSel = createSelect();
incomeSel.position(width / 3, height * 0.44);
incomeSel.option("Less than $20,000");
incomeSel.option("$20,000 - $30,000");
incomeSel.option("$30,000 - $40,000");
incomeSel.option("$40,000 - $50,000");
incomeSel.option("$50,000 - $60,000");
incomeSel.option("$60,000 - $70,000");
incomeSel.option("$70,000 - $80,000");
incomeSel.option("$80,000 - $90,000");
incomeSel.option("$90,000 - $100,000");
incomeSel.option("$100,000 - $110,000");
incomeSel.option("$110,000 - $120,000");
incomeSel.option("$120,000 - $130,000");
incomeSel.option("$130,000 - $140,000");
incomeSel.option("$140,000 - $150,000");
incomeSel.option("$150,000 - $160,000");
incomeSel.option("$160,000 - $170,000");
incomeSel.option("$170,000 - $180,000");
incomeSel.option("$180,000 - $190,000");
incomeSel.option("$190,000 - $200,000");
incomeSel.option("More than $200,000");
progSel = createSelect();
progSel.position(width / 3, 0.543 * height);
//progSel.option(FLL_EXP_PROGRAM_NAME);
//progSel.option("FLL Explore Camp");
//progSel.option("FLL Challenge Camp");
progSel.option(FLL_CHAL_PROGRAM_NAME);
//progSel.option("FLL Camps (per week)");
progSel.option(FTC_PROGRAM_NAME);
progSel.option(FTCFRC_PROGRAM_NAME);
//progSel.option("World Champs Trip 2024");
calBut = createButton("Calculate");
calBut.position(width * 0.45, height * 0.7);
calBut.mousePressed(calculate);
}
function writeMainText() {
background(186, 211, 254);
textAlign(CENTER);
textStyle(BOLD);
textSize(int(height / 15));
text("Girls of Steel Robotics", width / 2, height / 8);
text("Sliding Scale Fee Estimator", width / 2, height / 5);
textStyle(NORMAL);
textAlign(RIGHT);
textSize(int(height / 20));
text("Family Size: ", width / 3, height * 0.376);
text("Family Income: ", width / 3, height * 0.48);
text("Program: ", width / 3, height * 0.583);
textSize(int(height / 40));
text("Last updated August 5, 2024", width-5, height-10)
}
function calculate() {
writeMainText();
let incomeRange = incomeSel.value();
let message = " ";
//Get program and program cost
let program = progSel.value();
let progCost = getProgramCost(program);
//get family size and use it to high and low income
// boundaries for fee reduction
let size = int(famSizeSel.value());
let incomeScale = INCOME_SCALE[size - 2];
let incomeHigh = incomeScale[1];
let incomeLow = incomeScale[0];
//--------------------
//Calculate percentage of fees owed
//--------------------
//handle edge case of very low income
if (incomeRange == "Less than $20,000") {
lowEst = 0;
highEst = 0;
}
//and very high income
else if (incomeRange == "More than $200,000") {
lowEst = 1;
highEst = 1;
}
//otherwise get income reported from dropdown
//and calculate percentage owed for each
else {
incomeRange = incomeRange.split("-");
incomeTop = int(incomeRange[1].split(",")[0].split("$")[1] + "000");
incomeBottom = int(incomeRange[0].split(",")[0].split("$")[1] + "000");
print(incomeTop)
print(incomeBottom)
highEst = (incomeTop - incomeLow) / (incomeHigh - incomeLow);
lowEst = (incomeBottom - incomeLow) / (incomeHigh - incomeLow);
print(highEst)
print(lowEst)
//get rid of payments over 100%
if (highEst>1){
highEst = 1
}
if (lowEst>1){
lowEst = 1
}
}
//--------------------
//Calculate amounts owed
//--------------------
lowCost = round(lowEst * progCost);
highCost = round(highEst * progCost);
//--------------------
//Round down to $0 if the amount owed is less than $5
//--------------------
if (lowCost < 5) {
lowCost = 0;
}
if (highCost < 5) {
highCost = 0;
}
//--------------------
//Generate message string to be displayed
//--------------------
if (highCost == 0) {
message = "The cost for your family will be $0.";
} else if (lowEst >= 1) {
message = "The cost for your family will be $" + str(lowCost) + ".";
} else {
message =
"The cost for your family will be between $" +
str(lowCost) +
" and $" +
str(highCost) +
".";
}
//--------------------
//Display results to user
//--------------------
textAlign(CENTER);
textSize(int(height / 20));
text(message, width * 0.05, height * 0.825, width * 0.9, height * 0.15);
}
//--------------------
//Lookup cost of program selected
//--------------------
function getProgramCost(programName){
let cost = 0
if (programName == FLL_EXP_PROGRAM_NAME) {
cost = FLL_EXPLORE_COST;
} else if (programName == FLL_CHAL_PROGRAM_NAME) {
cost = FLL_CHALLENGE_COST;
} else if (programName == FTC_PROGRAM_NAME) {
cost = FTC_COST;
} else if (programName == FTCFRC_PROGRAM_NAME) {
cost = FRC_COST;
} else if (programName == "FLL Challenge Camp") {
cost = FLL_CHALLENGE_CAMP_COST;
} else if (programName == "FLL Explore Camp") {
cost =FLL_EXPLORE_CAMP_COST;
} else if (programName == "World Champs Trip 2024") {
cost = HOUSTON24_COST;
}
return cost;
}