You are on page 1of 4

B.

DODING
What would be the output of the following code?
@@@@@
***
@@@@@

Learning Activity:
1. Write a console program that asks the user to enter two integers, obtain
the two integers, and print sum, product, difference, and quotient.
Module VBModule
Sub Main()
Dim num1, num2, num3,sum,difference,product As Integer
Dim quotient As Double

Console.Write("Enter First Number: ")


num1 = Console.ReadLine

Console.Write("Enter Second Number: ")


num2 = Console.ReadLine

sum = num1 + num2


difference = num1 - num2
product = num1 * num2
quotient = num1 / num2

Console.WriteLine("Sum: " & sum)


Console.WriteLine("Differnce: " & difference)
Console.WriteLine("Product: " & product)
Console.WriteLine("Quotient: " & quotient)
Console.ReadLine()
End Sub
End Module
2. Write a console program that performs a simple payroll calculation. Use
the command window for input and output.
Module VBModule
Sub Main()
Dim bs, da, hr, gs As Integer

Console.Write("Enter Basic Salary: ")


bs = CInt(Console.ReadLine())

da = bs * 40 \ 100
hr = bs * 20 \ 100
gs = bs - (da + hr)

Console.WriteLine("Your Gross Salary is = " + gs.ToString())


Console.ReadLine()
End Sub
End Module

3. Write a program that asks the user to input the radius of a circle and
prints the circle’s diameter circumference, and area in the command
window.
Module VBModule
Sub Main()
Dim radius As Single = 0.0F
Dim area As Single = 0.0F

Console.Write("Enter the radius: ")


radius = Single.Parse(Console.ReadLine())

area = 3.14F * radius * radius

Console.WriteLine("Area of Circle: {0}",area)


End Sub
End Module
III. Coding: Analyzing the following code and identify the value of x.

1. 40000
2. 4
3. 25
4. V
5. VB2013

Coding:
1. Write a set of statements that sum the even integers between 1 and 20
using For/Next Signature.
Module VBModule
Sub Main()
Dim i, j As Integer
j=0
For i = 1 To 20
If i Mod 2 = 0 Then
j=j+i
End If
Next
Console.Write(j)
End Sub
End Module

2. Use any of the control structure that prints the following:


Module VBModule
Sub Main()
Dim a, b As Integer
Dim num As Integer = 5
For a = 1 To num
For b = 1 To a
Console.Write("* ")
Next
Console.WriteLine("")
Next
Console.ReadKey()
End Sub
End Module

Learning Activity:

II. Program Analysis


A.

You might also like