-
Notifications
You must be signed in to change notification settings - Fork 5
/
QuizGrades.cs
48 lines (43 loc) · 1.32 KB
/
QuizGrades.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using UnityEngine;
namespace Section.IfThen.Challenge04
{
public class QuizGrades : MonoBehaviour
{
/// Challenge Overview:
///
/// 01: Create a program that calculates random quiz grades and prints the average
/// 02: Print the average based on letter grade:
/// A = > 90
/// B = >= 80 but less than 90
/// C = > 70 but less than 80
/// F less than 70
///
public float quiz1, quiz2, quiz3, quiz4, quiz5;
// Start is called before the first frame update
void Start()
{
quiz1 = Random.Range(0f, 100f);
quiz2 = Random.Range(0f, 100f);
quiz3 = Random.Range(0f, 100f);
quiz4 = Random.Range(0f, 100f);
quiz5 = Random.Range(0f, 100f);
float average = (quiz1 + quiz2 + quiz3 + quiz4 + quiz5) / 5;
if (average > 90)
{
Debug.Log("You have an A");
}
else if (average >= 80 && average < 90)
{
Debug.Log("You have a B");
}
else if (average >= 70 && average < 80)
{
Debug.Log("You have a C");
}
else
{
Debug.Log("You have an F");
}
}
}
}