Você está na página 1de 6

Module Module1

Dim intPass As Integer 'variable which stores amount of passes as


an integer'

Dim intMerit As Integer 'variable which stores amount of merits as


an integer'

Dim intDistinction As Integer 'variable which stores amount of


distinctions as an integer'

Dim intTotal As Integer 'variable which stores total score as an


integer'

Dim intScore As Double 'variable used to store integer score'

Dim strOverallGrade As String 'variable which is used to store a


string grade'

Dim strHelp As String 'variable used to store string help'

Dim strExitCheck As String 'variable used to store string exit


check'

Sub Main()

Console.WriteLine("This is a BTEC Grade Calculator, for help,


type (help)") 'informs user of what the program is for, and asks them
to type help if they would like any help'

Console.WriteLine("To start the program press enter") 'asks


user to type enter for program to start'

strHelp = Console.ReadLine() 'reads if user enters help (form


of string/letters)'

If strHelp = "help" Then 'if the user enters help then...'

Console.WriteLine("########################################
################################")

Console.WriteLine("#This is a BTEC Grade Calculator, it is


a simple calculator which will #")

Console.WriteLine("#convert amount of unit grades achieved


to an overall grade by using #")

Console.WriteLine("#amount of passes,merits and


distinctions achieved. The program will #")
Console.WriteLine("#only convert the amount of
passes,merits and distinctions to an #")

Console.WriteLine("#overall grade if they all equal the


amount of 18, otherwise the #")

Console.WriteLine("#program will restart until all units


equal to 18. If alphabetical #")

Console.WriteLine("#value is entered, then the program will


let the user know that it is #")

Console.WriteLine("#an invalid input and they must enter a


numerical value has to be #")

Console.WriteLine("#entered before the program can


continue. The user has to enter a #")

Console.WriteLine("#number between the value of 0-18,


otherwise a message will display #")

Console.WriteLine("#informing the user that they entered a


number out of range, e.g 100. #")

Console.WriteLine("#The user can finally decide whether


they want to exit/restart the #")

Console.WriteLine("#program by choosing either Y/N. -1 can


also end program if user enters#")

Console.WriteLine("#it at either number of passes,merits or


distinctions stage. #")

Console.WriteLine("#Step 1:enter amount of passes achieved


#")

Console.WriteLine("#step 2:enter amount of merits achieved


#")

Console.WriteLine("#Step 3:enter amount of distinctions


achieved #")

Console.WriteLine("#Step 4:program will restart if totals


don't equal 18 #")

Console.WriteLine("#Step 5:If values equal 18, program will


continue #")

Console.WriteLine("#Step 6:Total points of passes,merits


and distinctions will display #")

Console.WriteLine("#Step 7:The total points will be


converted into an overall grade #")
Console.WriteLine("#Step 8:The total points and overall
grade will be displayed #")

Console.WriteLine("#Step 9:A message will ask user if they


wish to restart/exit program #")

Console.WriteLine("#Step 10: Program will either


exit/restart depending on users decision #")

Console.WriteLine("#an error will occur if you don't type


in any numerical values #")

Console.WriteLine("########################################
################################")

End If

Do

Console.WriteLine("enter number of passes") 'asks user to


enter amount of passes achieved'

Validate(intPass) 'validates whether user input passes is


correct (between 0-18)'

Console.WriteLine("enter number of merits") 'asks user to


enter amount of merits acheived'

Validate(intMerit) 'validates whether user input merits is


correct (between 0-18)'

Console.WriteLine("enter number of distinctions") 'asks


user to enter amount of distinctions achieved'

Validate(intDistinction) 'validates whether user input


distinctions is correct (between 0-18)'

Loop Until intPass + intMerit + intDistinction = 18 'Loops


until all passes, merits, distinctions achieved reach 18'

intTotal = (intPass * 70) + (intMerit * 80) + (intDistinction *


90) 'the method for working out the total overall score'

SetGrade() 'sets the grade for what the user achieved'

Console.WriteLine("your total score is: " & intTotal & "your


overall grade is:" & strOverallGrade) 'shows the user your total score
is.... followed by the overall score with the overall grade'

Console.WriteLine("do you wish to exit the program? Y/N?")


strExitCheck = Console.ReadLine() 'checks if user wishes to
exit/restart program'

If strExitCheck = "Y" Then End 'If user types Y then program


should exit'

End Sub 'command for the sub to end'

Sub Validate(ByRef variable As Integer) 'checks input entered by


user to make sure an integer/see if user wants to exit'

Dim strInput As String 'declares users input by using string'

Do 'tells the program to do something'

strInput = Console.ReadLine 'reads what exactly the user


has entered for string

If strInput = "-1" Then 'if user input is -1 then'

intPass = 0

intMerit = 0

intDistinction = 0

intTotal = 0

intScore = 0

strOverallGrade = " "

strHelp = " "

strInput = " "

End

End If

If IsNumeric(strInput) Then 'if the string input is numeric'

variable = strInput 'it should make the variable be


string (letter) input'

Else 'otherwise'

Console.WriteLine("invalid input, must be numeric")


'displays to the user that they entered a letter which is incorrect and
that only numbers are valid'

End If
If strInput < 0 Or strInput > 18 Then

Console.WriteLine("number must be between 0 & 18")

strInput = 0

End If

Loop Until IsNumeric(strInput) 'it should keep asking the user


until they enter a numeric value'

End Sub

Sub SetGrade() 'informs the user that this sub will be using for
setting users grade'

Select Case intTotal 'chooses the users total'

Case Is < 1300 'if the overall score is less than 1300'

strOverallGrade = "PPP" 'it should display a grade of


PPP'

Case Is < 1340 'if overall score is less than 1340'

strOverallGrade = "MPP" 'it should display a grade of


MPP'

Case Is < 1380 'if overall score is less 1380'

strOverallGrade = "MMP" 'it should display a grade of


MMP'

Case Is < 1420 'if overall score is less than 1420'

strOverallGrade = "MMM" 'it should display a grade of


MMM'

Case Is < 1460 'if overall score is less than 1460'

strOverallGrade = "DMM" 'it should display a grade of


DMM'

Case Is < 1500 'if overall score is less than 1500'

strOverallGrade = "DDM" 'it should display a grade of


DDM'

Case Is < 1530 'if overall score is less than 1530

strOverallGrade = "DDD" 'it should display a grade of


DDD'

Case Is < 1560 'if overall score is less than 1560'

strOverallGrade = "DDD*" 'it should display a grade of


DDD*'

Case Is < 1590 'if overall score is less than 1590'

strOverallGrade = "DD*D*" 'it should display a grade of


DD*D*'

Case Is <= 1620 'if overall score is/less than 1620'

strOverallGrade = "D*D*D*" 'it should display a grade


of D*D*D*'

End Select 'end of selecting scores'

End Sub 'end of sub routine'

End Module 'end of the program'

Você também pode gostar