Professional Documents
Culture Documents
PBL1 Sample Answer
PBL1 Sample Answer
Console.Writeline will print the output and move to the next line.
Console.Write will print the output and continue with the same line for the next output.
Console.ReadLine() will read the console input from the user, up until the next newline is
detected where the user can enter more than one character as input.
Console.Readkey() will get the user input, it accepts only a single character as input.
3. What does the word Dim stands for and what is it used for when writing a VB program?
Dim stands for the word Dimension, it is used to declare variables in VB program.
A constant is a type of data where the value will not change during runtime while a variable is a
type of data where the value can change during runtime.
Q5:
Module Module1
'Write a program that will ask the user to enter their name and country of origin
and display the information.
Sub Main()
Dim name, country As String
Console.Write("Enter your name: ")
name = Console.ReadLine()
Console.Write("Enter your country of origin: ")
country = Console.ReadLine()
Console.WriteLine("Your name is {0} and you are from {1}", name, country)
Console.ReadLine()
End Sub
End Module
Q6:
Module Module2
'Write a program to allow the user to input two integer values and then
'the program print the results of adding, subtracting, multiplying, and dividing
among the two values.
Sub Main()
Dim x, y As Integer
Console.Write("Enter your first integer value: ")
x = Console.ReadLine()
Console.Write("Enter your second integer value: ")
y = Console.ReadLine()
Console.WriteLine("The result of: ")
Console.WriteLine("Addition: {0}", x + y)
Console.WriteLine("Subtraction: {0}", x - y)
Console.WriteLine("Multiplication: {0}", x * y)
Console.WriteLine("Division: {0}", x / y)
Console.ReadLine()
End Sub
End Module
Q7:
Module Module3
'Write a program to convert a temperature in degrees Fahrenheit to degrees
Celsius.
'( Note Celsius = ( 5 /9 ) * ( Fahrenheit - 32 )
Sub Main()
Dim temp As Decimal
Console.WriteLine("What is the temperature today in {0}?", Chr(176) & "F")
temp = Console.ReadLine()
Console.WriteLine("The temperature today is {0}{1}", (5 / 9) * (temp - 32),
Chr(176) & "C")
Console.ReadLine()
End Sub
End Module
Q8:
Module Module8
Sub Main()
numberOfTrays = numberOfEggs \ 30
Module Module9
Sub Main()
Dim ratePerHour, totalPay As Single
Dim hoursWorked As Integer
Module Module5
Sub Main()
Dim hour, minute, seconds As Decimal
Console.WriteLine("Enter hour: ")
hour = Console.ReadLine()
Console.WriteLine("Enter minute: ")
minute = Console.ReadLine()
Console.WriteLine("Enter seconds: ")
seconds = Console.ReadLine()
Console.WriteLine("Your race time in seconds is: {0}", ((hour * 3600) +
(minute * 60) + seconds))
Console.ReadLine()
End Sub
End Module