In: Computer Science
Objective: Only attempt this assignment after
thoroughly reading Chapter 4 of the Visual Basic text. The
objective of the assignment is to write a program in Visual Basic
that applies decision logic within the program. Another objective
is to work through any syntax errors encountered (debugging) to
develop a correct solution that is free of errors.
Description: Create a working Visual Basic
solution using the Visual Studio IDE that accepts two numbers from
the user and displays one of the following messages: First is
larger, Second is larger, Numbers are equal. Provided your logic
from last week was correct, you can use the pseudocode and
flowchart from last's week's assignment to help you code your
solution. After you output one of the three messages, calculate the
average of the 2 numbers and display it for the user.
Requirements: For full credit, make sure that you
create your program using Visual Studio. Also make sure that the
program compiles (builds) successfully and without any errors. To
test the logic of your program, make sure to try many different
combinations of numbers. Ensure that in addition to displaying one
of the three messages to the user that you also calculate and
display the average as described.
This a a program in Visual Basic, it runs and compiles succesfully.
Imports System
Module operators
Sub Main()
Dim a As Double
Dim b As Double
a=Console.ReadLine()
b=Console.ReadLine()
Dim avg As Double= (a+b)/2
If (a = b) Then
Console.WriteLine("Numbers are equal")
Else If (a>b)
Console.WriteLine("First is larger")
Else
Console.WriteLine("Second is larger")
End If
Console.WriteLine("Average is {0}",avg)
End Sub
End Module
Here's the output for Input 12 and 9 respectively.