| 5 | } |
| 6 | |
| 7 | class ExceptionsDemo { |
| 8 | static double calculateWpm(int words, int seconds) throws InvalidDurationException { |
| 9 | if (seconds <= 0) { |
| 10 | throw new InvalidDurationException("seconds must be greater than 0"); |
| 11 | } |
| 12 | return (words * 60.0) / seconds; |
| 13 | } |
| 14 | |
| 15 | public static void main(String[] args) { |
| 16 | try { |
| 17 | System.out.println(calculateWpm(48, 30)); |
| 18 | System.out.println(calculateWpm(48, 0)); |
| 19 | } catch (InvalidDurationException e) { |
| 20 | System.err.println("Error: " + e.getMessage()); |
| 21 | } |
| 22 | } |
| 23 | } |
nothing calls this directly
no outgoing calls
no test coverage detected