Unity: Grade Average

Jake Boere
2 min readMay 1, 2021

When working on this example we’re going to use some if else statements. We’re going to calculate the total of 5 different quizzes and then have it display a message telling us if the grade was an A(90 or above), B(between 80 and 89), C(between 70 and 79) or F(69 or less). To start we need to make the variables for each quiz and a variable for the average then, give each quiz a random value and calculate the average by adding all the quizzes and dividing them by 5 since there are 5 quizzes.

After that we need to write the conditions for the message to display and the message itself. Fortunately the condition is pretty easy to write because we already know the condition which is if the average is above or between the numbers for it’s grade. Then we just need to write the message showing what grade the average was when calculated. Also when writing the if else statements you need to make sure that the first statement is an if statement otherwise this will not work.

--

--

Jake Boere

I am hard working Game development student learning as much about game development and unity as possible.