Recap - Making Decisions
Part of the Fundamentals section of Coddy's GO journey — lesson 43 of 109.
Challenge
MediumComplete the code to implement different conditional statements and print the results.
Try it yourself
package main
import "fmt"
func main() {
// Given variables
score := 85
grade := ""
// TODO: Use an if statement to check if score is greater than or equal to 90
// If true, set grade to "A"
// TODO: Use an else if statement to check if score is greater than or equal to 80
// If true, set grade to "B"
// TODO: Use an else if statement to check if score is greater than or equal to 70
// If true, set grade to "C"
// TODO: Use an else statement to handle scores below 70
// Set grade to "F"
// TODO: Print "Grade: B" using the grade variable
// TODO: Use a switch statement with the grade variable to print a message
// For "A", print "Excellent work!"
// For "B", print "Good job!"
// For "C", print "Satisfactory."
// For any other grade, print "You need to improve."
}All lessons in Fundamentals
4Comparison & Logical Operators
Comparison Operators - Part 1Comparison Operators - Part 2Logical AND OperatorLogical OR OperatorLogical NOT OperatorOperator Precedence BasicsRecap - Making Comparisons7Control Flow: Loops
What The `for` Loop ExplainedFor Loop - BasicFor Loop - Condition OnlyThe `break` KeywordThe `continue` KeywordNested LoopsRecap - Repeating Actions2Variables and Basic Data Types
What is a variableType Inference with `:=`Integers (int)Floating-Point NumbersBooleansStringsZero ValuesConstantsNaming ConventionsRecap - Variables and Types5Basic Input/Output
Formatted OutputFormat VerbsPrinting TypesGetting Basic User InputRecap - Input and Output8Functions
Understanding FunctionsDeclaring a FunctionCalling FunctionsFunction ParametersReturning a Single ValueReturning Multiple ValuesNamed Return ValuesFunction Scope BasicsRecap - Creating Reusable Code3Basic Operators
Arithmetic OperatorsDivision OperatorThe Modulo OperatorAssignment OperatorAugmented Assignment OperatorsIncrement and DecrementRecap - Calculations6Control Flow: Conditionals
The `if` StatementThe `else` KeywordThe `else if` KeywordVariable Shadowing in `if`Initializing VariablesThe `switch` StatementSwitch with ExpressionsSwitch without ExpressionThe `fallthrough` KeywordRecap - Making Decisions