Skip to content

Commit

Permalink
feat(4.3.3): Finish U4_L3_Activity_Three
Browse files Browse the repository at this point in the history
  • Loading branch information
101zh committed Oct 27, 2023
1 parent d24dbca commit a4859d4
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/main/java/Unit4/U4_L3_Activity_Three.java
Original file line number Diff line number Diff line change
@@ -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();
}
}

0 comments on commit a4859d4

Please sign in to comment.