We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3a24add commit 11cf1cbCopy full SHA for 11cf1cb
1 file changed
command-line/CommandlineArguments.java
@@ -0,0 +1,30 @@
1
+class CommandlineArguments{
2
+/**
3
+* Returns the sum of n number of command line arguments(Double datatype)
4
+* To execute run java CommandlineArguments 12.0 3.0 (Example)
5
+*/
6
+
7
+ public static void main(String s[])
8
+ {
9
+ double sum=0;
10
+ /**
11
+ * try-catch block to check for runtime input errors
12
+ *
13
+ */
14
15
+ try{
16
17
+ for(int i =0 ;i<s.length;i++)
18
19
+ sum =sum+Double.parseDouble(s[i]);
20
+ }
21
22
+ System.out.print("\n Sum is " + sum);
23
24
25
+ catch(Exception e){
26
+ System.out.print("\n please check input");
27
28
29
30
+}
0 commit comments