0% found this document useful (0 votes)
16 views6 pages

Basic Math Operations in Programming

The document contains a series of programs written in BASIC for performing various mathematical calculations, including product, area of a circle, simple interest, sum, average, and area of a triangle. It also includes a Visual Basic class for a calculator application with functions for basic arithmetic operations, trigonometric calculations, logarithm, square root, and percentage. The code features user input handling and displays results in a text box.

Uploaded by

Adetola Olamide
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views6 pages

Basic Math Operations in Programming

The document contains a series of programs written in BASIC for performing various mathematical calculations, including product, area of a circle, simple interest, sum, average, and area of a triangle. It also includes a Visual Basic class for a calculator application with functions for basic arithmetic operations, trigonometric calculations, logarithm, square root, and percentage. The code features user input handling and displays results in a text box.

Uploaded by

Adetola Olamide
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

INPUT " ENTER SECOND NUMBER:";Y

INPUT " ENTER THIRD NUMBER:";Z

LET PRODUCT = X*Y*Z

PRINT " THE PRODUCT IS:", PRODUCT

20 REM PROGRAM TO CALCULATE AREA OF CIRCLE

INPUT "20 ENTER RADIUS:";R

PI=3.141593

LET AREA = PI*R*R

PRINT " THE AREA IS:", AREA

30 REM PROGRAM TO CALCULATE SIMPLE INTEREST

INPUT "30 ENTER THE PRINCIPAL:";P

INPUT " ENTER THE RATE:";R

INPUT " ENTER THE TIME:";T

LET SI=(P*R*T)/100

PRINT " THE SIMPLE INTEREST:", SI

40 REM PROGRAM TO CALCULATE SUM

INPUT "40 FIRST NUMBER:";Y

INPUT " SECOND NUMBER:";Z

LET SUM = Y+Z

PRINT " THE SUM IS:", SUM

50 REM PROGRAM TO CALCULATE AVERAGE


INPUT "50 ENTER FIRST NUMBER:";A

INPUT " ENTER SECOND NUMBER:";B

INPUT " ENTER THIRD NUMBER:";C

LET AVERAGE = (A+B+C)/3

PRINT " THE AVERAGE IS:",AVERAGE

60 REM PROGRAM TO CALCULATE AREA OF TRIANGLE

INPUT "60 ENTER BASE:";B

INPUT " ENTER HEIGHT:";H

LET AREA = (B*H)/2

PRINT " THE AREA IS:", AREA

70 REM PROGRAM TO CALCULATE PRODUCT

INPUT "7 ENTER FIRST NUMBER:";P

INPUT " ENTER SECOND NUMBER:";Q

INPUT " ENTER THIRD NUMBER:";R

INPUT " ENTER FOURTH NUMBER:";S

LET PRODUCT = P*Q*R*S

PRINT " THE PRODUCT IS:",PRODUCT

80 REM PROGRAM TO CALCULATE AVERAGE

INPUT "8 ENTER FIRST NUMBER:";A

INPUT " ENTER SECOND NUMBER:";B

INPUT " ENTER THIRD NUMBER:";C

INPUT " ENTER FOURTH NUMBER:";D

INPUT " ENTER FIFTH NUMBER:";E


LET AVERAGE = (A+B+C+D+E)/5

PRINT " THE AVERAGE IS:",AVERAGE

OOU CSC

Public Class Form1


Dim firstnum As Integer
Dim secondnum As Integer
Dim operation As Integer
Dim operator_selector As Boolean = False
Private Sub Button13_Click(sender As Object, e As EventArgs) Handles [Link]
firstnum = [Link]
[Link] = "0"
operator_selector = True
operation = 4 ' = /
End Sub

Private Sub Button9_Click(sender As Object, e As EventArgs) Handles [Link]


firstnum = [Link]
[Link] = "0"
operator_selector = True
operation = 3 ' = *
End Sub

Private Sub Button10_Click(sender As Object, e As EventArgs) Handles [Link]


If [Link] <> "0" Then
[Link] += "3"
Else
[Link] = "3"
End If
End Sub

Private Sub Button11_Click(sender As Object, e As EventArgs) Handles [Link]


If [Link] <> "0" Then
[Link] += "2"
Else
[Link] = "2"
End If
End Sub

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles [Link]


firstnum = [Link]
[Link] = "0"
operator_selector = True
operation = 2 ' = -
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles [Link]
If [Link] <> "0" Then
[Link] += "6"
Else
[Link] = "6"
End If
End Sub

Private Sub Button7_Click(sender As Object, e As EventArgs) Handles [Link]


If [Link] <> "0" Then
[Link] += "5"
Else
[Link] = "5"
End If
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles [Link]


If [Link] <> "0" Then
[Link] += "7"
Else
[Link] = "7"
End If
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles [Link]


If [Link] <> "0" Then
[Link] += "8"
Else
[Link] = "8"
End If
End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles [Link]


If [Link] <> "0" Then
[Link] += "9"
Else
[Link] = "9"
End If
End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles [Link]


firstnum = [Link]
[Link] = "0"
operator_selector = True
operation = 1 ' = +

End Sub

Private Sub Button15_Click(sender As Object, e As EventArgs) Handles [Link]


If Not ([Link](".")) Then
[Link] += "."
End If
End Sub

Private Sub Button14_Click(sender As Object, e As EventArgs) Handles [Link]


[Link] = "0"
End Sub
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles [Link]
If [Link] <> "0" Then
[Link] += "4"
Else
[Link] = "4"
End If
End Sub

Private Sub Button12_Click(sender As Object, e As EventArgs) Handles [Link]


If [Link] <> "0" Then
[Link] += "1"
Else
[Link] = "1"
End If
End Sub

Private Sub Button16_Click(sender As Object, e As EventArgs) Handles [Link]


If [Link] <> "0" Then
[Link] += "0"
Else
[Link] = "1"
End If
End Sub

Private Sub Button17_Click(sender As Object, e As EventArgs) Handles [Link]


If operator_selector = True Then
secondnum = [Link]
If operation = 1 Then
[Link] = firstnum + secondnum
ElseIf operation = 2 Then
[Link] = firstnum - secondnum
ElseIf operation = 3 Then
[Link] = firstnum * secondnum
Else
If secondnum = 0 Then
[Link] = "Error!"
ElseIf operation = 4 Then
[Link] = firstnum / secondnum
End If
End If
operator_selector = False

End If
End Sub

Private Sub Button21_Click(sender As Object, e As EventArgs) Handles [Link]


Dim Sine = [Link]([Link])
Sine = [Link](Sine)
[Link] = [Link]
End Sub

Private Sub Button20_Click(sender As Object, e As EventArgs) Handles [Link]


Dim Cos As Double = [Link]([Link])
Cos = [Link](Cos)
[Link] = [Link]()
End Sub

Private Sub Button19_Click(sender As Object, e As EventArgs) Handles [Link]


Dim Tan As Double = [Link]([Link])
Tan = [Link](Tan)
[Link] = [Link]()
End Sub

Private Sub Button18_Click(sender As Object, e As EventArgs) Handles [Link]


Dim Log As Double
Log = [Link]([Link])
Log = Math.Log10(Log)
[Link] = [Link](Log)
End Sub

Private Sub Button22_Click(sender As Object, e As EventArgs) Handles [Link]


Dim Sqrt As Double
Sqrt = [Link]([Link])
Sqrt = [Link](Sqrt)
[Link] = [Link](Sqrt)
End Sub

Private Sub Button23_Click(sender As Object, e As EventArgs) Handles [Link]


Dim Sq As Double
Sq = [Link]([Link])
[Link] = [Link](Sq * Sq)
End Sub

Private Sub Button24_Click(sender As Object, e As EventArgs) Handles [Link]


Dim Sq As Double
Sq = [Link]([Link])
[Link] = [Link](Sq * Sq * Sq)
End Sub

Private Sub Button25_Click(sender As Object, e As EventArgs) Handles [Link]


Dim Percent As Double
Percent = [Link]([Link]) / [Link](100)
[Link] = [Link](Percent)
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles [Link]

End Sub
End Class

You might also like