Exercise
Several multiplication tables, (use do while)
Objetive
Write a Visual Basic (VB.Net) program that display multiplication tables from 2 to 6 using nested "do...while" loops.
Code
' Importing necessary namespaces
Imports System
Public Class Program
Public Shared Sub Main()
' Declare variables for multiplication and table number
Dim number As Integer = 2
' Outer do-while loop to print multiplication tables from 2 to 6
Do
' Print the table number
Console.WriteLine("Multiplication table for " & number)
' Declare the multiplier
Dim multiplier As Integer = 1
' Inner do-while loop to display the multiplication results for the current table
Do
' Print the result of the multiplication
Console.WriteLine(number & " x " & multiplier & " = " & (number * multiplier))
multiplier += 1 ' Increment the multiplier
Loop While multiplier <= 10 ' Continue while the multiplier is less than or equal to 10
Console.WriteLine() ' Add a blank line between tables
number += 1 ' Increment the number to print the next table
Loop While number <= 6 ' Continue until the number reaches 6
End Sub
End Class