Advertisement
axyd

Go Grade Calculator

Sep 13th, 2017
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.49 KB | None | 0 0
  1. //go 1.6
  2.  
  3. //Grade Calculator
  4.    
  5.  
  6. package main
  7. import "fmt"
  8. func main() {
  9.     score := 0
  10.    
  11.     fmt.Printf("\n\tEnter your score:  ")
  12.     fmt.Scanln(&score)
  13.    
  14.     fmt.Printf(sc2gr(score))   
  15. }
  16.  
  17. func sc2gr(score int) string{
  18.     grade := "F"
  19.    
  20.     if(score>0 && score<100){
  21.         if(score>90) {
  22.             grade = "A"
  23.         }else if(score>80) {
  24.             grade = "B"
  25.         }else if(score>70) {
  26.             grade = "C"
  27.         }else if(score>60) {
  28.             grade = "D"
  29.         }
  30.     }else {
  31.         fmt.Printf("\n\tERROR: Invalid score\n")
  32.     }
  33.    
  34.     return grade
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement