ics2programmingprocessing Grades //Jason Cameron //Ms. Basaraba //2023-11-07 // This program finds your avg for a class until you enter a negative number. float totalGrade, userInputGrade, currentAvg; // totalGrade is all the inputs added together, userInputGrade is the current input & currentAvg is what the current avg is int inputsTotal; // total count of user inputs to calculate avg void title() { println("\t\t\tGradesCalculator"); } //program introduction void introduction() { title(); println("This program adds your grades up together and gives you your final avg"); } void userInput() { //while (userInputGrade>1 || grade<0) userInput(); userInputGrade=getFloat("Enter your grade (out of 100) for this assignemnt, e.g. 75.3. Your current Avg is " + currentAvg); // get the user input } void calculateGrade() { totalGrade += userInputGrade; currentAvg = totalGrade / inputsTotal; } void setup() { introduction(); while (userInputGrade>=0) { userInput(); inputsTotal++; calculateGrade(); } JOptionPane.showMessageDialog(null, "Your final grade is " + (totalGrade / inputsTotal) + "%"); } Times Table // Jason Cameron // Ms. Basaraba // 2023-11-06 // This Program will generate a times table when you specify the base & middle value int middleValue; int baseValue; String tab = "\t"; String tab4 = "\t\t\t\t"; void setup() { size(0, 0); askUser(); } void calculateTable() { println(tab4+tab+tab, " Base Value", tab, " Multiplied by", tab, " Result"); for (int i=(middleValue -5); i<=middleValue+6; i++) { int tableCalculation = baseValue * i; println(tab4+tab+tab+tab, baseValue, tab + "*" + tab, i, tab+ "="+tab, tableCalculation); } }; void askUser() { println(tab4+tab4 + "WELCOME TO THE TIMES TABLE CALCULATOR"); println(tab4+"You will input a middle value and a base value, the middle value represents the middle of the 12 times table."); println(tab4 + "E.g. if you set middle value to 5 and base of 3, the program will output 3 * 0, 3*1 … 3*11"); middleValue = getInt(tab4+tab4+"Please Enter Your Middle Value"); baseValue = getInt(tab4+tab4+" Please Enter Your Base Value"); calculateTable(); } a+b calculator //Jason Cameron //Ms. Basaraba //2023-11-07 //guessing game int num1,num2; //program title void title() { println("\t\t\tCalculating game"); } //program introduction void introduction() { title(); println("Thisprogram adds to numbers"); } void userInput() { num1=getInt("Enter your first number"); // get the user input num2=getInt("Enter your second number"); // get the user input } void display() { int answer; answer = num1+num2; println("You entered", num1, "and", num2, "and the answer is", answer); } void setup(){ introduction(); while (num1!=2&&num2!=2) { userInput(); display(); }} Mailing Calculator //Jason Cameron //Ms. Basaraba //2023-11-13 //Mail cost calculator based off of error trapped user input package weight. boolean firstRun = true; // if the program has been run before ( to show if you continue or exit) boolean onMenu = true; // if the program is currently on the menu float packageWeight; // weight of the package (in grams) int menuOption; // which menu option is going to be selected. float cost; // final cost of the letter. void setup () { intro(); mainMenu(); } void intro() { title(); println("Welcome!, please follow the menu below!"); println("If you want to calculate your package's cost, enter 1, if you want to exit, enter 2"); } void title() { println("MAILING COST CALCULATOR"); } void goodbye() { println("Good bye! Hope you enjoyed this calculator by Jason Cameron"); } void mainMenu() { onMenu = true; userInput(); if (menuOption == 1) { // if you want to calculate display(); } else goodbye(); // if you want to exit. } void userInput() { if (onMenu == true) { if (firstRun) { println("1. Calculate Cost"); } else { println("1. Continue"); } print("2. Exit"); menuOption = getInt(""); if (menuOption > 2 || menuOption < 1) { // error trapping JOptionPane.showMessageDialog(null, "Invalid option, must be either 1 (calculate) or 2 (exit)"); intro(); userInput(); } } else if (onMenu == false) { packageWeight = getFloat("Enter your package's weight in grams. E.G. 208.3 or 306"); if (packageWeight < 1) { // error trapping JOptionPane.showMessageDialog(null, "Invalid option, the package weight must be positive (greater than one)"); userInput(); } } } void calculateCost() { if (packageWeight <= 100) { cost = 1.8; } else if (packageWeight <= 200) { cost = 2.95; } else if (packageWeight <= 300) { cost = 4.1; } else if (packageWeight <= 400) { cost = 4.7; } else if (packageWeight <= 500) { cost = 5.05; } else { cost = 5.05; packageWeight -= 500; int remaining = ceil(packageWeight/50); cost += float(nf(remaining * 1.2, 0, 2)); // round to 2 decimal places to fix floating point issues. } } void display() { onMenu = false; firstRun = false; userInput(); calculateCost(); println("Your final cost will be $" + cost); delay(400); // delay for 0.4s so the user has time to read the output. mainMenu(); }