Skip to content

Commit

Permalink
added input checking for scala
Browse files Browse the repository at this point in the history
  • Loading branch information
luke5542 committed Aug 6, 2015
1 parent eaaa900 commit b80dc57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions sieve-of-eratosthenes/dlang/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ void main(char[][] args)
}
catch(Exception e)
{
writeln("Invalid input. Expected a single number.");
exit(1);
}

Expand Down
10 changes: 9 additions & 1 deletion sieve-of-eratosthenes/scala/sieve_scala.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ import Array._

object sieve_scala {
def main(args: Array[String]) {
var max = Integer.parseInt(args(0));
var max = 0;
try {
max = Integer.parseInt(args(0));
} catch {
case ex: NumberFormatException => {
println("Invalid input. Expected a single number.");
System.exit(1);
}
}

val start = System.currentTimeMillis;

Expand Down

1 comment on commit b80dc57

@dan-c-underwood
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional fix for #11

Please sign in to comment.