-
Notifications
You must be signed in to change notification settings - Fork 206
Expand file tree
/
Copy pathhousehold.java
More file actions
81 lines (71 loc) · 2.02 KB
/
household.java
File metadata and controls
81 lines (71 loc) · 2.02 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import java.util.Scanner;
public class household {
int members;
String ID;
int income;
void get()
{
Scanner sc= new Scanner(System.in);
System.out.println("Enter the number of members in the household :");
members = sc.nextInt();
System.out.println("Enter the ID of the household : ");
ID = sc.next();
for (int i = 0 ; i < members ; i++)
{
int o;
System.out.println("Enter the income of " + (i+1) + " person :");
o = sc.nextInt();
income += o;
}
}
void print()
{
System.out.println("Identification number : " + ID);
System.out.println("Income : " + income);
}
static int pov_level(int n)
{
int p;
p = 7500 + (950 *(n -2));
return p;
}
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
int n;
System.out.println("Enter the number of households : ");
n = sc.nextInt();
household ho[] = new household[30];
for (int i = 0; i < n ;i++)
{
ho[i] = new household();
System.out.println("Enter details \n --------------\n");
ho[i].get();
}
int x = 0;
for (int i = 0 ; i < n ;i++){
x += ho[i].income;
}
int h = x/n;
System.out.println("Households with income greater than average \n ------------------\n");
for (int i = 0 ; i < n ;i++){
if (ho[i].income >= h)
{
ho[i].print();
}
}
int count = 0;
for (int i = 0 ; i < n ; i++)
{
int xo;
xo = pov_level(ho[i].members);
if (xo > ho[i].income){
count += 1;
}
}
double percen = (count/(double)n);
double percent = percen*100;
System.out.println("\n");
System.out.println("Percent of households below poverty line : "+ percent);
}
}