From a4859d48808eadf562b640dd4c9a92657c566bf8 Mon Sep 17 00:00:00 2001 From: 101zh <67253838+101zh@users.noreply.github.com> Date: Fri, 27 Oct 2023 23:39:43 +0000 Subject: [PATCH] feat(4.3.3): Finish U4_L3_Activity_Three --- src/main/java/Unit4/U4_L3_Activity_Three.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/main/java/Unit4/U4_L3_Activity_Three.java diff --git a/src/main/java/Unit4/U4_L3_Activity_Three.java b/src/main/java/Unit4/U4_L3_Activity_Three.java new file mode 100644 index 0000000..5711341 --- /dev/null +++ b/src/main/java/Unit4/U4_L3_Activity_Three.java @@ -0,0 +1,47 @@ +package Unit4; + +import java.util.Scanner; + +public class U4_L3_Activity_Three { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + int num = scanner.nextInt(); + + if (num > 0 && num < 50) { + int i = 0; + for (int j = num; j <= 50; j++) { + System.out.print(j + " "); + i++; + if (i == 5) { + System.out.println(""); + i = 0; + } + } + } else { + System.out.println("error"); + } + + scanner.close(); + } + + public static void alternateAnswer(String[] args) { + Scanner scanner = new Scanner(System.in); + + int num = scanner.nextInt(); + int constant = num % 10; + + if (num <= 0 || num >= 50) { + System.out.println("error"); + } else { + for (int i = num; i <= 50; i++) { + if ((i - constant) % 5 == 0) { + System.out.println(); + } + System.out.print(i + " "); + } + } + + scanner.close(); + } +}