Display a function Learn programming Visual Basic (VB.net)

Lesson:

Basic Data Types


Exercise:

Display a function 8


Objetive:

Create a program to "draw" the graphic of the function y = (x-4)2 for integer values of x ranging -1 to 8. It will show as many asterisks on screen as the value obtained for "y", like this:

*************************
****************
*********
****
*

*
****
*********
****************


Code:

Imports System
Public Class exercise57
    Public Shared Sub Main()
        Dim x, y, j As Integer

        For x = -1 To 8
            y = (x - 4) * (x - 4)

            For j = 0 To y - 1
                Console.Write("*")
            Next

            Console.WriteLine()
        Next
    End Sub
End Class