Monday, July 22, 2019

Grade Equivalent Using Switch Statement Using Go


Write a program using a switch statement to ask the students its grade and then the program will display the numerical equivalent of the given grade and its remarks on the screen based on the following given scale.

Grade Interval          Equivalent Grade        Remarks

97..100                  1.0                               EXCELLENT
94..96                      1.25                             EXCELLENT
91..93                      1.5                               VERY GOOD
88..90                      1.75                             VERY GOOD
85..87                      2.0                               GOOD
82..84                      2.25                             GOOD
79..81                      2.5                               SATISFACTORY
76..78                      2.75                             FAIR
75                            3.0                               PASSED
Below 75                 5.0                               FAILED




Sample Program Output


Program Listing

grade.go

/* grade.go
Authors  
Mr. Jake R. Pomperada
Mr. Rollyn M.  Moises
Mr. Sunday Latergo
Date : July 22, 2019  Monday  5:15 AM
 */

package main

import "fmt"

func main() {

var grade int32

fmt.Print("\n")
fmt.Print("\tGrade Equivalent Using Switch Statement")
fmt.Print("\n\n")
fmt.Print("\tPlease enter your grade : ")
fmt.Scanf("%d",&grade)

fmt.Print("\n")

switch (grade) {
case 97,98,99,100 :
   fmt.Println("\tYour grade equivalent is 1.0")
   fmt.Println("\tThe remarks is EXCELLENT.")
case 94,95,96 :
fmt.Println("\tYour grade equivalent is 1.25")
fmt.Println("\tThe remarks is EXCELLENT.")
case 91,92,93 :
   fmt.Println("\tYour grade equivalent is 1.5")
   fmt.Println("\tThe remarks is VERY GOOD.")
case 88,89,90 :
fmt.Println("\tYour grade equivalent is 1.75")
fmt.Println("\tThe remarks is VERY GOOD.")
case 85,86,87 :
   fmt.Println("\tYour grade equivalent is 2.0")
   fmt.Println("\tThe remarks is GOOD.")
case 82,83,84 :
fmt.Println("\tYour grade equivalent is 2.5")
fmt.Println("\tThe remarks is GOOD.")
case 79,80,81 :
   fmt.Println("\tYour grade equivalent is 2.25")
   fmt.Println("\tThe remarks is SATISFACTORY.")
case 76,77,78 :
fmt.Println("\tYour grade equivalent is 2.75")
fmt.Println("\tThe remarks is FAIR.")
  case 75 :
fmt.Println("\tYour grade equivalent is 3.0")
fmt.Println("\tThe remarks is PASSED.")
  default :
fmt.Println("\tYour grade equivalent is 5.0")
fmt.Println("\tThe remarks is FAILED.")
 }

fmt.Print("\n")
fmt.Print("\tEnd of Program")
fmt.Print("\n")
}





1 comment:

  1. Good day! Can you help me on how to code this in If Else Statement? Thanks 😊

    ReplyDelete