package week5; /*Please create an algorithm and a coded solution based on your created algorithm for the following question: For this task, you are required to write a program that prints out a multiplication table based on a number entered by a user. The multiplication table should be printed from 1 to 10 and be formatted as shown below: 5 X 1 = 5 5 X 2 = 10 5 X 3 = 15 Etc. This table should be generated using a while loop. If one of the following numbers is triggered: 21 or 32 A message advising the user they have triggered a forbidden number should appear, then the loop should break. Algorithm (Pseudocode): Start Prompt the user to enter a number for which the multiplication table will be generated. Read the user input (the number). Initialize a counter variable i = 1 to keep track of the multiplication steps. Start a while loop that will continue as long as i <= 10: Inside the loop, check if i is either 21 or 32. If true, print a forbidden message and break the loop. Otherwise, calculate the product: product = number * i. Print the multiplication result in the format: number X i = product. Increment i by 1 to move to the next multiplication step. End the loop when i exceeds 10 or a forbidden number is triggered. End the program. */ import java.util.Scanner; public class PracQ3 { public static void main(String[] args) { Scanner myInput = new Scanner(System.in); System.out.println("Please enter a number to display its multiplicaiton table: "); int multiNum = myInput.nextInt(); int count = 1; int tempAns; while(count <=10) { tempAns = multiNum * count; System.out.printf("%d X %d = %d\n", multiNum, count, tempAns); if(tempAns == 21 || tempAns == 32) { System.out.println("A forbidden number has been triggered!"); break; } count++; } } }