From 8e1ea4127566d7b70b27205ffc7aae5d17982477 Mon Sep 17 00:00:00 2001 From: legitimately_the_1984th_year_of_the_common_era_&_anno_domini_designations <85363779+literally1984@users.noreply.github.com> Date: Mon, 21 Jun 2021 15:07:29 -0700 Subject: [PATCH] Add files via upload --- Main.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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