Menu
Coddy logo textTech

Recap - Making Decisions

Part of the Fundamentals section of Coddy's GO journey — lesson 43 of 109.

challenge icon

Challenge

Medium

Complete 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