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.

The exact text is Good job!.

The exact text is Grade: B.

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 the exact text from the instructions 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 the exact text from the instructions
  // For "C", print "Satisfactory."
  // For any other grade, print "You need to improve."
}

All lessons in Fundamentals

Practice on your own: Online Go compiler