Advertisement
axyd

VB Grade Calculator

Sep 30th, 2017
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Rextester.Program.Main is the entry point for your code. Don't change it.
  2. 'Compiler version 11.0.50709.17929 for Microsoft (R) .NET Framework 4.5
  3.  
  4. Imports System
  5. Imports System.Collections.Generic
  6. Imports System.Linq
  7. Imports System.Text.RegularExpressions
  8.  
  9. Namespace Rextester
  10.     Public Module Program
  11.         Public Sub Main(args() As string)
  12.        
  13.             Dim score As Integer
  14.            
  15.             'get user input
  16.            Console.Writeline("\n\tEnter score: ")
  17.             score= Console.ReadLine()
  18.            
  19.             'show grade
  20.            Console.WriteLine("\n\tYour grade: " & calcGrade(score) )
  21.         End Sub
  22.        
  23.         'convert number score to letter grade
  24.        Function calcGrade(ByVal sco As Double) As String
  25.             Dim gra As String
  26.  
  27.             'detect invalid score
  28.            If sco<0 Or sco>100 Then
  29.                 gra= "invalid"
  30.                 return gra
  31.             End If
  32.  
  33.             Select Case sco
  34.                 Case >=90
  35.                     gra= "A"
  36.                 Case >=80
  37.                     gra= "B"
  38.                 Case >=70
  39.                     gra= "C"
  40.                 Case >=60
  41.                     gra= "D"
  42.                 Case Else
  43.                     gra= "F"
  44.             End Select
  45.  
  46.             return gra
  47.         End Function
  48.        
  49.        
  50.     End Module
  51. End Namespace
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement