Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. public class Ex4 {
  2.  
  3. public static void main(String[] args) {
  4. if(args.length < 1 | args.length > 3){System.out.println("number of
  5. arguments invalid");}
  6.  
  7. else{
  8. try{
  9. double a = Double.parseDouble(args[0]);
  10. double b = Double.parseDouble(args[1]);
  11. double c = Double.parseDouble(args[2]);
  12.  
  13. if(args.length ==1){System.out.println(a);}
  14.  
  15. else if (args.length == 2){System.out.println(a*b);}
  16.  
  17. else if(args.length == 3){System.out.println(a*b*c);}
  18.  
  19. }
  20. catch(NumberFormatException e){System.out.println("invalid operation");}
  21. }
  22. }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement