SHARE
TWEET

Untitled

a guest Jun 18th, 2019 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top