-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPhysicalExaminate.java
More file actions
83 lines (69 loc) · 1.95 KB
/
PhysicalExaminate.java
File metadata and controls
83 lines (69 loc) · 1.95 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
82
83
import java.util.Scanner;
public class PhysicalExaminate {
// 시력분포 상수(0.0에서 0.1단위로 21개
static final int VMAX = 21;
//멤버변수
static class PhyscData {
String name;
int height;
double vision;
//생성자
PhyscData(String name, int height, double vision){
this.name = name;
this.height = height;
this.vision = vision;
}
}
//키 평균값 메서드
static double aveHeight(PhyscData[] dat) {
double sum = 0;
for(int i=0; i< dat.length; i++) {
sum += dat[i].height;
}
return sum/dat.length;
}
//시력 분포
static void distVision(PhyscData[] dat,int[] dist) {
int i = 0;
dist[i]=0;
for(i=0; i<dat.length; i++) {
if(dat[i].vision >=0.0 && dat[i].vision <= VMAX/10.0) {
dist[(int)(dat[i].vision*10)]++;
}
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
//신체 데이터 x
PhyscData[] x = {
new PhyscData("박현규", 162, 0.3),
new PhyscData("함진아", 173, 0.7),
new PhyscData("최윤미", 175, 2.0),
new PhyscData("홍연의", 171, 1.5),
new PhyscData("이수진", 168, 0.4),
new PhyscData("김영준", 174, 1.2),
new PhyscData("박영규", 169, 0.8)
};
int[] vdist = new int[VMAX]; //시력분포
System.out.println("===신체 검사 리스트===");
System.out.println("이름 키 시력");
System.out.println("-------------------");
for(int i=0; i<x.length; i++) {
System.out.printf("%-8s%3d%5.1f\n",
x[i].name,x[i].height, x[i].vision);
}
System.out.printf("\n평균키: %5.1fcm\n", aveHeight(x));
distVision(x, vdist);
System.out.println("\n시력 분포");
for(int i=0; i<VMAX; i++) {
// System.out.printf("%3.1f~: %2d명\n", i/10.0, vdist[i] );
// 사람수( :명)
// "*" 그래프로
System.out.printf("%3.1f~:", i/10.0);
for(int j=0; j<vdist[i];j++)
System.out.print("*");
System.out.println();
}
}
}