import java.io.*;
import java.util.Random;
public class Main {
DataCreater creater = new DataCreater();
Data data = new Data(
creater.age(),
creater.bmi(),
creater.sex(),
creater.smoker(),
creater.bloodPressure());
Grader.agePoint(data.age),
Grader.bmiPoint(data.bmi),
Grader.smokerPoint(data.smoker, data.sex),
Grader.sexPoint(data.sex),
Grader.bloodPressurePoint(data.bloodPressure));
int totalPoint = point.age + point.bmi + point.smoker + point.sex + point.bloodPressure;
CrisisRate rate = Grader.crisisRate(totalPoint);
System.
out.
println("年齢:" + data.
age + " " + point.
age + "点"); System.
out.
println("BMI:" + data.
bmi + " " + point.
bmi + "点"); System.
out.
println("性別:" + data.
sex + " " + point.
sex + "点"); System.
out.
println("喫煙:" + (data.
smoker ? "あり" : "なし") + " " + point.
smoker + "点"); System.
out.
println("血圧:" + data.
bloodPressure.
systolic + "/" + data.
bloodPressure.
diastolic + " " + point.
bloodPressure + "点"); System.
out.
println("合計" + totalPoint
+ "点"); System.
out.
println("10年間に脳卒中を発症する確率は" + rate.
low + "%以上" + rate.
high + "%未満です"); }
}
class Data {
int age;
int bmi;
boolean smoker;
BloodPressure bloodPressure;
Data
(int age,
int bmi,
String sex,
boolean smoker, BloodPressure bloodPressure
) { this.age = age;
this.bmi = bmi;
this.sex = sex;
this.smoker = smoker;
this.bloodPressure = bloodPressure;
}
}
class Grader {
static CrisisRate crisisRate(int point) {
if (point <= 10) {
return new CrisisRate(0, 1);
} else if (point <= 17){
return new CrisisRate(1, 2);
} else if (point <= 22) {
return new CrisisRate(2, 3);
} else if (point <= 25) {
return new CrisisRate(3, 4);
} else if (point <= 27) {
return new CrisisRate(4, 5);
} else if (point <= 29) {
return new CrisisRate(5, 6);
} else if (point <= 30) {
return new CrisisRate(6, 7);
} else if (point <= 32) {
return new CrisisRate(7, 8);
} else if (point <= 33) {
return new CrisisRate(8, 9);
} else if (point <= 34) {
return new CrisisRate(9, 10);
} else if (point <= 36) {
return new CrisisRate(10, 12);
} else if (point <= 39) {
return new CrisisRate(12, 15);
} else if (point <= 42) {
return new CrisisRate(15, 20);
} else {
return new CrisisRate(20, 100);
}
}
static int agePoint(int age) {
if (age < 45) {
return 0;
} else if (age < 50) {
return 5;
} else if (age < 55) {
return 6;
} else if (age < 60) {
return 12;
} else if (age < 65) {
return 16;
} else if (age < 70) {
return 19;
} else {
}
}
static int smokerPoint
(boolean smoker,
String sex
) { if (smoker) {
switch (sex) {
case "男":
return 4;
case "女":
return 8;
default:
}
} else {
return 0;
}
}
static int sexPoint
(String sex
) { switch (sex) {
case "男":
return 6;
case "女":
return 0;
default:
}
}
static int bmiPoint(int bmi) {
if (bmi < 25) {
return 0;
} else if (bmi < 30) {
return 2;
} else {
return 3;
}
}
static int bloodPressurePoint(BloodPressure pressure) {
int systolicPoint = systolicBloodPressurePoint(pressure.systolic);
int diastolicPoint = diastolicBloodPressurePoint(pressure.diastolic);
return (systolicPoint >= diastolicPoint) ? systolicPoint : diastolicPoint;
}
static int systolicBloodPressurePoint(int pressure) {
if (pressure < 120) {
return 0;
} else if (pressure < 130) {
return 3;
} else if (pressure < 140) {
return 6;
} else if (pressure < 160) {
return 8;
} else if (pressure < 180) {
return 11;
} else {
return 13;
}
}
static int diastolicBloodPressurePoint(int pressure) {
if (pressure < 80) {
return 0;
} else if (pressure < 85) {
return 3;
} else if (pressure < 90) {
return 6;
} else if (pressure < 100) {
return 8;
} else if (pressure < 110) {
return 11;
} else {
return 13;
}
}
}
int age;
int bmi;
int smoker;
int sex;
int bloodPressure;
Point(int age,
int bmi,
int smoker,
int sex,
int bloodPressure
) { this.age = age;
this.bmi = bmi;
this.smoker = smoker;
this.sex = sex;
this.bloodPressure = bloodPressure;
}
}
class CrisisRate {
int low;
int high;
CrisisRate(int low, int high) {
this.low = low;
this.high = high;
}
}
class BloodPressure {
int systolic;
int diastolic;
BloodPressure(int systolic, int diastolic) {
this.systolic = systolic;
this.diastolic = diastolic;
}
}
class DataCreater {
int age() {
return r.nextInt(69 - 40 + 1) + 40;
}
if (r.nextBoolean()) {
return "男";
} else {
return "女";
}
}
BloodPressure bloodPressure() {
return new BloodPressure(r.nextInt(190 - 110) + 110, r.nextInt(120 - 70) + 70);
}
int bmi() {
return r.nextInt(40 - 15) + 15;
}
boolean smoker() {
return r.nextBoolean();
}
}