You are on page 1of 4

 Write the code to execute and verify the results of the following situations:

A. Ask the user for a temperature value in celcius (C) and convert it to Fahrenheit (F) value.
HINT : Formula is F = C * 9 / 5 + 32
Syntax

Sub temperature()
Dim c As Single, f As Single
c = InputBox("enter value in celcius")
f = c * 9 / 5 + 32
Debug.Print "tempeature in farenhite:" & f
End Sub

Output :

B. Ask the user to input a valuein inches and convert it to cms

HINT: Formula Is 1 inch = 2.54cms

Syntax:

Sub length()
Dim inch As Single, cms As Single
inch = InputBox("enter value in inches")
cms = inch * 2.54
Debug.Print "lenght in cms is:" & cms
End Sub

Output:

C. Ask the user to input value in miles and convert in kilometers.

HINT: 1 Mile = 1.609344 kms


Syntax :

Sub tempreature()
Dim mile As Single, kms As Single
mile = InputBox("enter value in miles")
kms = mile * 1.609344
Debug.Print "lenght in kms is:" & kms
End Sub
Output :

D. Ask the user to input the value of the sides of a cube and display the total surface area and volume of the
cube.
HINT:
1. Total surface area of cube : 6 * I^2
2. Volume of cube: I * I * I
Syntax:

Sub tempreature()
Dim i As Single
i = InputBox("enter side of cube")
area = 6 * i * i
volume = i * i * i
Debug.Print "area of cuboid is:" & area
Debug.Print "volume of cuboid is:" & volume
End Sub
Output:

You might also like