-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariableArguments.java
More file actions
54 lines (49 loc) · 1.74 KB
/
Copy pathvariableArguments.java
File metadata and controls
54 lines (49 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
public class variableArguments {
// static void showlist(int start,String...A){
// for(int i=0;i<A.length;i++){
// System.out.println(start+"."+A[i]);
// start++;
// }
// }
// public static void main(String []args) {
// // show(0,1,2,3);
// showlist(5,"jhlfw","jkl","ehbwef","hjgefwhj");
// }
// FINDING MAX VALUE//
// static int max(int...A){
// if(A.length==0)return Integer.MIN_VALUE;
// int max=A[0];
// for(int i=1;i<A.length;i++)
// if(A[i]>max)max=A[i];
// return max;
// }public static void main(String[] args) {
// System.out.println(max());
// System.out.println(max(10,23));
// System.out.println(max(203,7683));
// }
// FINDING SUM OF ELEMENTS//
// static int sum(int...A){
// int s=0;
// for(int i=0;i<A.length;i++)
// s=s+A[i];
// return s;
// }
// public static void main(String[] args) {
// System.out.println(sum(1,2,3,4));
// }
// DISCOUNT CALCULATION//
static double discount(double...p){
double s=0;
for(int i=0;i<p.length;i++){
s=s+p[i];
}
if(s<500)
return s*0.10;
else if(s>=500 && s<1000)return s*0.15;
else return s*0.20;
}public static void main(String[] args) {
System.out.println(discount(50,100,200,150));
System.out.println(discount(100,20,30,50));
System.out.println(discount(1100,1100,1100));
}
}