Multiply if not zero Learn programming Visual Basic (


Flow Control


Multiply if not zero


Write a Visual Basic ( program to ask the user for a number; if it is not zero, then it will ask for a second number and display their sum; otherwise, it will display "0"


Imports System
Public Class exercise16
    Public Shared Sub Main()
        Dim x, y As Integer
        Console.Write("enter x:")
        x = System.Convert.ToInt32(System.Console.ReadLine())

        If x <> 0 Then
            Console.Write("enter y:")
            y = System.Convert.ToInt32(System.Console.ReadLine())
            Console.WriteLine("the product of {0} and {1} is {2}", x, y, x * y)
        End If

        If x = 0 Then Console.Write("0")
    End Sub
End Class

Juan A. Ripoll - Systems Tutorials and Programming Courses ©  All rights reserved.  Legal Conditions.