Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Ex4 {
- public static void main(String[] args) {
- if(args.length < 1 | args.length > 3){System.out.println("number of
- arguments invalid");}
- else{
- try{
- double a = Double.parseDouble(args[0]);
- double b = Double.parseDouble(args[1]);
- double c = Double.parseDouble(args[2]);
- if(args.length ==1){System.out.println(a);}
- else if (args.length == 2){System.out.println(a*b);}
- else if(args.length == 3){System.out.println(a*b*c);}
- }
- catch(NumberFormatException e){System.out.println("invalid operation");}
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement