Guest User

Untitled

a guest
Oct 16th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. public class ExceptionExample {
  2.  
  3. public static void main(String[] args) {
  4. System.out.println(calculateSalary(8, 3));
  5. }
  6.  
  7. public static double calculateSalary(int hours, double hourRate) {
  8. if(hours < 0) {
  9. throw new IllegalArgumentException("Tundide arv ei tohi olla negatiivne. Sisend oli " + hours);
  10. }
  11. /*if(hourRate < 0) {
  12. throw new IllegalArgumentException("Tunnitasu ei tohi olla negatiivne. Sisend oli " + hourRate);
  13. }
  14. if(hourRate < 2.97) {
  15. throw new IllegalArgumentException("Tunnitasu ei tohi alla miinimumi 2.97. Sisend oli " + hourRate);
  16. }*/
  17.  
  18. if(hourRate < 2.97) {
  19. throw new IllegalArgumentException("Tunnitasu ei tohi olla negatiivne v�i alla miinimumpalga. Sisend oli " + hourRate);
  20. }
  21.  
  22.  
  23. return hours * hourRate;
  24. }
  25. }
Add Comment
Please, Sign In to add comment