'F' → Fullscreen
import java.util.Scanner;
public class Program{ public static void main(String[] args) { Scanner input = new Scanner(System.in);
System.out.println("--- Demo 1 - Counting Multiples ---");
System.out.print("Choose a number: "); int number = input.nextInt(); System.out.print("List how many multiples of " + number + "? "); int count = input.nextInt();
int sum = number; // Sum is used to keep track of current multiple
for (int i = 0; i < count; i++) { System.out.print(sum + " "); // Display horizontally sum += number; }
input.nextLine(); // Consume newline System.out.print("\nPress enter to continue..."); input.nextLine();
// ----------------------------------------------------------------------------- }}import java.util.Scanner;
public class Program{ public static void main(String[] args) {22 collapsed lines
Scanner input = new Scanner(System.in);
System.out.println("--- Demo 1 - Counting Multiples ---");
System.out.print("Choose a number: "); int number = input.nextInt(); System.out.print("List how many multiples of " + number + "? "); int count = input.nextInt();
int sum = number; // Sum is used to keep track of current multiple
for (int i = 0; i < count; i++) { System.out.print(sum + " "); // Display horizontally sum += number; }
input.nextLine(); // Consume newline System.out.print("\nPress enter to continue..."); input.nextLine();
// -----------------------------------------------------------------------------
System.out.println("\n--- Demo 2 - Square Tables ---");
System.out.print("Enter row count: "); int rows = input.nextInt();
System.out.println("\nNumber\tSquare"); System.out.println("----------------");
for (int i = 1; i <= rows; i++) { System.out.println(i + "\t" + (i * i)); } }}Your program output should something similar to the sample output below.
--- Demo 1 - Counting Multiples ---Choose a number: 5List how many multiples of 5? 105 10 15 20 25 30 35 40 45 50Press enter to continue...
--- Demo 2 - Square Tables ---Enter row count: 12
Number Square----------------1 12 43 94 165 256 367 498 649 8110 10011 12112 144You may write your reflection answers as comments at the bottom of your code.
Submit your activity and reflection answers to the appropriate dropbox.