53.1k views
5 votes
Create an application in VB that allows the user to enter an object’s mass, velocity, and height and displays the object’s KE and PE. The application should have a two functions: KineticEnergy that accepts an object’s mass (kilograms) and velocity (meters/second) as arguments and PotentialEnergy that accepts an object’s mass (kilograms), acceleration due to gravity (m/s2 ), and height (meters) as arguments. The function should return the objects KE and PE (3 decimal places).

1 Answer

7 votes

Answer:

see explaination

Step-by-step explanation:

Module VBModule

Function KineticEnergy(ByVal mass As Decimal, ByVal velocity As Decimal) As Decimal

Dim result As Decimal

result = 0.5*mass*velocity*velocity

KineticEnergy = result

End Function

Sub Main()

Dim mass = Console.ReadLine()

Dim velocity = Console.ReadLine()

Console.WriteLine(FormatNumber(CDbl(KineticEnergy(mass,velocity)), 3))

End Sub

End Module

User DGrady
by
4.1k points