| Summary: | Java Exception Error when input text that is not number | ||
|---|---|---|---|
| Product: | 2021 CS3343 Hall Admission System | Reporter: | amble3232 |
| Component: | Scoring and Weighting Record Section | Assignee: | Azim <mohamazim2> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | chpang22-c |
| Priority: | Normal | ||
| Version: | unspecified | ||
| Hardware: | PC | ||
| OS: | Windows | ||
|
Description
amble3232
2021-12-04 15:16:16 HKT
For now, the system only accepts the number string and special strings like float number and DSE characters. Therefore when having other strings like "Other String", the system will throw a Java Exception directly as Java predefine error. Adding a function to allow validate input and telling users the input have an error. I will pass it to the developer to design a new function to do validation. I just added a class for validation of the input. The class is named Validation.
To validate the score, use the following method. I also added validation for other input. Now the bug is solved.
Solution:
===============
public static boolean validationScore(String input, String academicType) {
Double temp = 0.0;
if(input==null||academicType==null) return false;
if(academicType.equals("DSE")) {
if(input.equals("5**")||input.equals("5*")||input.equals("5")||input.equals("4")||input.equals("3")||input.equals("2")||input.equals("1")||input.equals("U"))
return true;
}else {
if(!checkDouble(input))
return false;
temp = Double.parseDouble(input);
if(temp<=4.3 && temp>=0)
return true;
}
return false;
}
|