Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim score_Number_Guessing_Game As Integer
- Sub file_writing_and_reading()
- Dim path As String
- Dim line, line1, line2, line3, line4 As String
- path = "H:\yr 10\Year 10 computer sci\files\test.txt"
- FileOpen(1, path, OpenMode.Output)
- Console.WriteLine("enter the first line")
- line = Console.ReadLine
- Console.WriteLine("please enter the second line")
- line1 = Console.ReadLine
- Console.WriteLine("please enter the third line")
- line2 = Console.ReadLine
- Console.WriteLine("Please enter the fourth line")
- line3 = Console.ReadLine
- Console.WriteLine("please enter the last line")
- line4 = Console.ReadLine
- PrintLine(1, line)
- PrintLine(1, line1)
- PrintLine(1, line2)
- PrintLine(1, line3)
- PrintLine(1, line4)
- FileClose(1)
- path = "H:\yr 10\Year 10 computer sci\files\test.txt"
- FileOpen(1, path, OpenMode.Input)
- Do While Not EOF(1)
- line = LineInput(1)
- Console.WriteLine(line)
- line1 = LineInput(1)
- Console.WriteLine(line1)
- line2 = LineInput(1)
- Console.WriteLine(line2)
- line3 = LineInput(1)
- Console.WriteLine(line3)
- line4 = LineInput(1)
- Console.WriteLine(line4)
- Console.ReadLine()
- Loop
- End Sub
- Sub OverFlow_error()
- Dim crash As Integer
- Dim overflow As Integer
- crash = 0
- Console.WriteLine("Press enter to cause an over flow error")
- Console.ReadLine()
- crash = 1
- While crash = 1
- overflow = overflow + 10000
- Console.WriteLine(overflow)
- If overflow = 2147470000 Then
- crash = 0
- Console.WriteLine("press enter again to crash")
- Console.ReadLine()
- overflow = overflow + 20000
- Console.Clear()
- Main()
- Console.WriteLine(overflow)
- Console.ReadLine()
- overflow = 0
- End If
- End While
- End Sub
- Sub currency_converter()
- Dim choice As String ' varibles
- Dim con As String
- Dim gbp As Decimal
- Console.WriteLine("service charge: 5% if under £500 and 3% if over £500") ' this tells them that there is a service charge
- Console.WriteLine("Please enter the amount you would like to convert (gbp): ") ' this asks them to enter the amount of money they would like to convert
- gbp = Console.ReadLine()
- If Decimal.TryParse(gbp, gbp) Then
- Console.WriteLine("valid. number = " & gbp)
- If gbp <= 499 Then ' This part calculates the service charge
- gbp = gbp * 0.95 ' 5% if its under £500
- End If
- If gbp >= 500 Then ' 3% if its over £500
- gbp = gbp * 0.97
- End If
- If gbp < 0 Or gbp > 999999 Then 'this puts a limit on the amount they can convert to 999999
- Console.WriteLine("please enter a valid number between 0 and 999999") ' this tells that the number is too high or low
- Console.WriteLine("please press enter to continue")
- Console.ReadLine() ' the next 3 lines loops the program
- Console.Clear()
- Main()
- End If
- Console.WriteLine()
- Console.WriteLine("Please enter the currency you would like to convert into: ")
- Console.WriteLine()
- Console.WriteLine("******************************")
- Console.WriteLine()
- Console.WriteLine("1: United states Dollar (USD)")
- Console.WriteLine("2: Euro (EUR)")
- Console.WriteLine("3: Australian Dollar (AUD) ")
- Console.WriteLine("4: Canadian Dollar (CAD) ")
- Console.WriteLine("5: Swiss Franc (CHF) ")
- Console.WriteLine("6: Hong Kong Dollar (HKD) ") ' this lists all of the currencys they can convert into
- Console.WriteLine("7: Japanese Yen (JPY) ")
- Console.WriteLine("8: Mexican Peseo (MXN) ")
- Console.WriteLine("9: Indian Rupee (INR) ")
- Console.WriteLine("10: New Zealand Dollar (NZD) ")
- Console.WriteLine()
- Console.WriteLine("******************************")
- Console.WriteLine()
- con = Console.ReadLine()
- If (con <= 0) Or (con >= 11) Then ' this makes sure its between 1 - 10
- Console.WriteLine("please enter a number between 1 and 10")
- Console.WriteLine("please press enter to continue")
- Console.ReadLine() ' loops program if its not between 1 - 10
- Console.Clear()
- Main()
- End If
- While con = 1
- Console.WriteLine("you will get " & gbp * 1.61 & " usd For " & gbp & " gbp (after service charge) ") ' converts gbp to usd
- con = 0
- Console.WriteLine("Do you want convert another currency? [yes/no]") 'asks if you want to convert another currency
- choice = Console.ReadLine()
- If choice = "yes" Then ' if choice is yes then it loops the program
- Console.Clear()
- Main()
- Else
- End
- End If
- End While
- While con = 2
- Console.WriteLine("you will get " & gbp * 1.22 & " eur for " & gbp & " gbp (after service charge) ") ' converts euros
- con = 0
- Console.WriteLine("Do you want convert another currency? [yes/no]")
- choice = Console.ReadLine()
- If choice = "yes" Then
- Console.Clear()
- Main()
- Else
- End
- End If
- End While
- While con = 3
- Console.WriteLine("you will get " & gbp * 1.55 & "aud for " & gbp & " gbp (after service charge) ") ' converts aud
- con = 0
- Console.WriteLine("Do you want convert another currency? [yes/no]")
- choice = Console.ReadLine()
- If choice = "yes" Then
- Console.Clear()
- Main()
- Else
- End
- End If
- End While
- While con = 4
- Console.WriteLine("you will get " & gbp * 1.59 & " cad for " & gbp & " gbp (after service charge) ") ' converts cad
- con = 0
- Console.WriteLine("Do you want convert another currency? [yes/no]")
- choice = Console.ReadLine()
- If choice = "yes" Then
- Console.Clear()
- Main()
- Else
- End
- End If
- End While
- While con = 5
- Console.WriteLine("you will get " & gbp * 1.46 & " chf for " & gbp & " gbp (after service charge) ") ' converts chf
- con = 0
- Console.WriteLine("Do you want convert another currency? [yes/no]")
- choice = Console.ReadLine()
- If choice = "yes" Then
- Console.Clear()
- Main()
- Else
- End
- End If
- End While
- While con = 6
- Console.WriteLine("you will get " & gbp * 1.25 & " hdk for " & gbp & " gbp (after service charge) ") ' converts hdk
- con = 0
- Console.WriteLine("Do you want convert another currency? [yes/no]")
- choice = Console.ReadLine()
- If choice = "yes" Then
- Console.Clear()
- Main()
- Else
- End
- End If
- End While
- While con = 7
- Console.WriteLine("you will get " & gbp * 1.31 & " jpy for " & gbp & " gbp (after service charge) ") ' converts jpy
- con = 0
- Console.WriteLine("Do you want convert another currency? [yes/no]")
- choice = Console.ReadLine()
- If choice = "yes" Then
- Console.Clear()
- Main()
- Else
- End
- End If
- End While
- While con = 8
- Console.WriteLine("you can get " & gbp * 2.12 & " mxn for " & gbp & " gbp (after service charge) ") ' converts mxn
- con = 0
- Console.WriteLine("Do you want convert another currency? [yes/no]")
- choice = Console.ReadLine()
- If choice = "yes" Then
- Console.Clear()
- Main()
- Else
- End
- End If
- End While
- While con = 9
- Console.WriteLine("you can get " & gbp * 8.39 & " inr for " & gbp & " gbp (after service charge) ") ' converts inr
- con = 0
- Console.WriteLine("Do you want convert another currency? [yes/no]")
- choice = Console.ReadLine()
- If choice = "yes" Then
- Console.Clear()
- Main()
- Else
- End
- End If
- End While
- While con = 10
- Console.WriteLine("you can get " & gbp * 1.98 & " nzd for " & gbp & " gbp (after service charge) ") ' converts nzd
- con = 0
- Console.WriteLine("Do you want convert another currency? [yes/no]")
- choice = Console.ReadLine()
- If choice = "yes" Then
- Console.Clear()
- Main()
- Else
- End
- End If
- End While
- End If
- End Sub
- Sub caluclator()
- Dim number_1 As Decimal
- Dim number_2 As Decimal
- Dim opr As String
- Dim sum As Decimal
- Dim choice As String
- Console.WriteLine("please enter your first number: ")
- number_1 = Console.ReadLine()
- Console.WriteLine()
- Console.WriteLine("please enter your second number: ")
- number_2 = Console.ReadLine()
- Console.WriteLine()
- Console.WriteLine("Please pick an operator from the list below : ")
- Console.WriteLine()
- Console.WriteLine("***************")
- Console.WriteLine()
- Console.WriteLine("1: + ")
- Console.WriteLine("2: - ")
- Console.WriteLine("3: x ")
- Console.WriteLine("4: / ")
- Console.WriteLine()
- Console.WriteLine("***************")
- opr = Console.ReadLine
- While opr = 1
- sum = number_1 + number_2
- Console.WriteLine("The 2 numbers added equals: " & sum & "")
- opr = 0
- Console.WriteLine()
- Console.WriteLine("would you like to use the calculator again? [yes/no]")
- choice = Console.ReadLine()
- End While
- If choice = "yes" Then
- Console.Clear()
- Main()
- End If
- While opr = 2
- sum = number_1 - number_2
- Console.WriteLine("The 2 numbers subtracted equals: " & sum & "")
- opr = 0
- Console.WriteLine()
- Console.WriteLine("would you like to use the calculator again? [yes/no]")
- choice = Console.ReadLine()
- End While
- If choice = "yes" Then
- Console.Clear()
- Main()
- Else : End
- End If
- While opr = 3
- sum = number_1 * number_2
- Console.WriteLine("The 2 numbers timed equals: " & sum & "")
- opr = 0
- Console.WriteLine()
- Console.WriteLine("would you like to use the calculator again? [yes/no]")
- choice = Console.ReadLine()
- End While
- If choice = "yes" Then
- Console.Clear()
- Main()
- Else : End
- End If
- While opr = 4
- sum = number_1 - number_2
- Console.WriteLine("The 2 numbers subtracted equals: " & sum & "")
- opr = 0
- Console.WriteLine()
- Console.WriteLine("would you like to use the calculator again? [yes/no]")
- choice = Console.ReadLine()
- End While
- If choice = "yes" Then
- Console.Clear()
- Main()
- Else : End
- End If
- While opr = 2
- sum = number_1 / number_2
- Console.WriteLine("The 2 numbers divided equals: " & sum & "")
- opr = 0
- Console.WriteLine()
- Console.WriteLine("would you like to use the calculator again? [yes/no]")
- choice = Console.ReadLine()
- End While
- If choice = "yes" Then
- Console.Clear()
- Main()
- Else : End
- End If
- End Sub
- Sub guessing_game()
- Dim confirm As String
- Dim guess As Integer
- Dim mysterynumber As Integer
- Dim choice As String
- Randomize()
- mysterynumber = CInt(Math.Ceiling(Rnd() * 100))
- If mysterynumber < 1 Then
- Console.WriteLine("Error Number is smaller than 1!")
- Console.ReadLine()
- End If
- If mysterynumber > 100 Then
- Console.WriteLine("Error Number is bigger than 100!")
- Console.ReadLine()
- End If
- guess = 0
- While guess = 0
- Console.WriteLine("score :" & score_Number_Guessing_Game & " ")
- Console.WriteLine("please enter a guess between 1 and 100.")
- guess = Console.ReadLine
- If guess > mysterynumber Then
- guess = 0
- Console.WriteLine("your guess is too high")
- ElseIf guess < mysterynumber Then
- guess = 0
- Console.WriteLine("Your guess is too low")
- ElseIf guess = mysterynumber Then
- Console.WriteLine("well done you've guessed correctly!")
- Console.WriteLine("Score + 1")
- score_Number_Guessing_Game = score_Number_Guessing_Game + 1
- Console.WriteLine("would you like to play again? [Yes/No] ")
- choice = Console.ReadLine()
- If choice = "yes" Then
- guessing_game()
- Console.Clear()
- Else
- Console.WriteLine("are you sure you will lose your current score of " & score_Number_Guessing_Game & " [Yes/No] ")
- confirm = Console.ReadLine
- If confirm = "No" Then
- Console.Clear()
- guessing_game()
- If confirm = "Yes" Then
- Console.Clear()
- score_Number_Guessing_Game = 0
- Main()
- End If
- End If
- End If
- End If
- End While
- End Sub
- Sub Main()
- Dim selection As Integer
- Console.WriteLine("****************************")
- Console.WriteLine()
- Console.WriteLine("1: OverFlow error")
- Console.WriteLine("2: currecny converter")
- Console.WriteLine("3: caluclator")
- Console.WriteLine("4: Guessing game")
- Console.WriteLine("5: File writing and reading")
- Console.WriteLine()
- Console.WriteLine("****************************")
- selection = Console.ReadLine()
- If selection = 1 Then
- Console.Clear()
- OverFlow_error()
- ElseIf selection = 2 Then
- Console.Clear()
- currency_converter()
- ElseIf selection = 3 Then
- Console.Clear()
- caluclator()
- ElseIf selection = 4 Then
- Console.Clear()
- guessing_game()
- ElseIf selection = 5 Then
- Console.Clear()
- file_writing_and_reading()
- End If
- Console.ReadLine()
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement