| Summary: | Invalid input of letter will not be checked | ||
|---|---|---|---|
| Product: | Group37 | Reporter: | PAN Zhenyuan <pzyhihihi> |
| Component: | calculation operation | Assignee: | feiwu25-c |
| Status: | RESOLVED FIXED | ||
| Severity: | enhancement | CC: | danielsuendaniel, tommyhonym |
| Priority: | --- | ||
| Version: | unspecified | ||
| Hardware: | PC | ||
| OS: | Windows | ||
|
Description
PAN Zhenyuan
2020-11-07 19:30:27 HKT
problem is using "while(!sc.hasNextInt())". It ignore all character and noway to show the problem input to user.
solution is edit the code from:
while (!sc.hasNextInt())
sc.next();
int input = sc.nextInt();
sc.nextLine();
return input;
to:
String input = sc.nextLine();
try {
int option = Integer.parseInt(input);
return option;
} catch (NumberFormatException e) {
throw new InvaildInputOptionException(String.valueOf(input));
}
|