-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ10.java
More file actions
57 lines (47 loc) · 1.28 KB
/
Copy pathQ10.java
File metadata and controls
57 lines (47 loc) · 1.28 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
package Assignment_01;
import java.util.Scanner;
public class Q10 {
public static void main(String[] args) {
City arr[] = new City[4];
Scanner obj = new Scanner(System.in);
String p;
int l, m, n, o;
for (int i = 0; i < 4; i++) {
System.out.println("Enter the name of the city");
p = obj.nextLine();
System.out.println("enter no of maruti_k10 zen_astelo wagnor and maruti_sx4");
l = obj.nextInt();
m = obj.nextInt();
n = obj.nextInt();
o = obj.nextInt();
obj.nextLine();
arr[i] = new City(p, l, m, n, o);
}
l = m = n = o = 0;
for (int i = 0; i < 4; i++) {
l += arr[i].maruti_k10;
m += arr[i].zen_astelo;
n += arr[i].wagnor;
o += arr[i].maruti_sx4;
}
System.out.println("No of maruti_k10=" + l);
System.out.println("No of zen_aastelo=" + m);
System.out.println("No of wagnor=" + n);
System.out.println("No of marut_sx4=" + o);
obj.close();
}
}
class City {
String city_name;
int maruti_k10;
int zen_astelo;
int wagnor;
int maruti_sx4;
City(String city_name, int maruti_k10, int zen_astelo, int wagnor, int maruti_sx4) {
this.city_name = city_name;
this.maruti_k10 = maruti_k10;
this.zen_astelo = zen_astelo;
this.wagnor = wagnor;
this.maruti_sx4 = maruti_sx4;
}
}