0% found this document useful (0 votes)
31 views5 pages

CS Corr of Ass2

The document contains code for two Visual Basic programs. The first program accepts three numbers as input and calls a function to determine the smallest number. The second program calculates the interest earned on an investment based on inputs for the amount, interest rate, and number of years.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views5 pages

CS Corr of Ass2

The document contains code for two Visual Basic programs. The first program accepts three numbers as input and calls a function to determine the smallest number. The second program calculates the interest earned on an investment based on inputs for the amount, interest rate, and number of years.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Correction of assessment 2 on visual basic

Name: BONAMALLY Mahessing


Grade: G12A
1.Write a program that will accept three numbers and pass the numbers to a
procedure to determine the smallest number.
Module Module1

Function Findsmall(ByVal num1 As Integer, ByVal num2 As Integer, ByVal num3 As Integer) As
Integer

Dim result As Integer

If (num1 < num2) Then

result = num1

Else

result = num2

End If

If (num2 < num3) Then

result = num2

Else

result = num3

End If

If (num3 < num1) Then

result = num3

Else

result = num1

End If

Findsmall = result

End Function
Sub Main()

Dim a As Integer

Dim b As Integer

Dim c As Integer

Dim res As Integer

Console.WriteLine("Enter value a")

a = Console.ReadLine()

Console.WriteLine("Enter value b")

b = Console.ReadLine()

Console.WriteLine("Enter value c")

c = Console.ReadLine()

res = Findsmall(a, b, c)

Console.WriteLine("Smallest value is :" & res)

Console.ReadLine()

End Sub

End Module
RESULT:
2.Write a function to calculate the amount of interest earned on an
investment. The amount invested, the interest rate and the number
of years the investment lasts, are to be entered by the user.

RESULT:
CODING:
Module Module1

Function Interests(ByVal P As Double, ByVal R As Double, ByVal T As Double) As Double

Interests = ((P * R * T) / 100)

End Function

Sub Main()

Dim amount_invested As Double

Dim rate As Double

Dim time As Double

Dim int As Double

Console.WriteLine("Enter the amount invested")

amount_invested = Console.ReadLine()

Console.WriteLine("Enter the interest rate")

rate = Console.ReadLine()

Console.WriteLine("Enter number of years the investment lasts")

time = Console.ReadLine()

int = Interests(amount_invested, rate, time)

Console.WriteLine("Amount of interest is :" & int)

Console.ReadLine()

End Sub

End Module

You might also like