-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcapgemini_06.java
More file actions
66 lines (43 loc) · 1.18 KB
/
Copy pathcapgemini_06.java
File metadata and controls
66 lines (43 loc) · 1.18 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
55
56
57
58
59
60
61
62
63
64
65
66
/*
Problem Statement –
A function is there which tells how many dealerships there are and the total number of cars in each dealership.
Your job is to calculate how many tyres would be there in each dealership.
Input
3
4 2
4 0
1 2
Output
20
16
8
There are total 3 dealerships
dealerships1 contains 4 cars and 2 bikes
dealerships2 contains 4 cars and 0 bikes
dealerships3 contains 1 cars and 2 bikes
Total number of tyres in dealerships1 is (4 x 4) + (2 x 2) = 20
Total number of tyres in dealerships2 is (4 x 4) + (0 x 2) = 16
Total number of tyres in dealerships3 is (1 x 4) + (2 x 2) = 8
*/
import java.util.Scanner;
public class capgemini_06 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int m=n;
int a[]=new int[m];
int t=0,s;
while(n>0){
s=0;
int car=sc.nextInt();
int bike=sc.nextInt();
s+=4*car+2*bike;
a[t]=s;
t++;
n--;
}
sc.close();
for(int i=0;i<m;i++)
System.out.println(a[i]);
}
}