diff --git a/Main.java b/Main.java index 25f4ded..d00502e 100644 --- a/Main.java +++ b/Main.java @@ -1,4 +1,5 @@ import java.util.Scanner; + class Main { public static void main(String[] args) { System.out.print("\033[H\033[2J"); @@ -18,6 +19,11 @@ public static void main(String[] args) { if (inputnumtimes.charAt(keeptrack) >= '0' && inputnumtimes.charAt(keeptrack) <= '9') { keeptrack = keeptrack + 1; } + else if (inputnumtimes.substring(0,1).equals("-")) { + inputgoodornot = false; + System.out.println("Error: Entered number must not be negative. Try again?"); + break; + } else { inputgoodornot = false; System.out.println("Error: User input must not include characters other than numbers. Try again?"); @@ -35,4 +41,4 @@ public static void main(String[] args) { System.out.println(""); System.out.println("'" + inputchar + "'" + " was printed " + numoftimes + " times"); } -} +} \ No newline at end of file