我想知道如何在 Java 中编写多个条件。
for (int i = 1; i <= pqrst; i++) {
P = P + "{" + Pxcoor[i] + "," + Pycoor[i] + "} ; ";
Q = Q + "{" + Qxcoor[i] + "," + Qycoor[i] + "} ; ";
R1 = R1 + "{" + Rxcoor[i] + "," + Rycoor[i] + "} ; ";
S = S + "{" + Sxcoor[i] + "," + Sycoor[i] + "} ; ";
T = T + "{" + Txcoor[i] + "," + Tycoor[i] + "} ; ";
if (i >= 2) {
rrdistance += (((Rxcoor[i] - Rxcoor[i - 1]) / FINALBOXWIDTH(bitmap_Source)) * 0.04);//durations in seconds
printerval += (((Rxcoor[i] - Pxcoor[i]) / FINALBOXWIDTH(bitmap_Source)) * 0.04);
qsdistance += (((Sxcoor[i] - Qxcoor[i]) / FINALBOXWIDTH(bitmap_Source)) * 0.04);
heartrate += (1500 / (rrdistance / 0.04));
//amplitude in mV
pamp = (( (trial[1] - Pycoor[i]) / (double)FINALBOXWIDTH(bitmap_Source)) * 0.1);
qamp = (( (Qycoor[i] - trial[i]) / (double)FINALBOXWIDTH(bitmap_Source)) *0.1);
ramp = (( (trial[1] - Rycoor[i]) / (double)FINALBOXWIDTH(bitmap_Source)) *0.1);
samp = (( (Sycoor[i] - trial[i]) / (double)FINALBOXWIDTH(bitmap_Source)) *0.1);
tamp = (( (trial[1] - Tycoor[i]) / (double)FINALBOXWIDTH(bitmap_Source)) *0.1);
}
}
DecimalFormat df = new DecimalFormat("#.##");
rrdistance = rrdistance / (pqrst - 1);
RRdistance = RRdistance + " " + rrdistance + " " + "seconds";
PRinterval = PRinterval + " " + printerval + " " + "seconds";
QSdistance = QSdistance + " " + qsdistance + " " + "seconds";
HeartRate = HeartRate + " " + heartrate + " " + "bpm";
Pamp = Pamp + " " + df.format(pamp) + " " + "mV";
Qamp = Qamp + " " + df.format(qamp) + " " + "mV";
Ramp = Ramp + " " + df.format(ramp) + " " + "mV";
Samp = Samp + " " + df.format(samp) + " " + "mV";
Tamp = Tamp + " " + df.format(tamp) + " " + "mV";
coordinate.setText("Peak coordinates:" + "\n" + P + "\n" + Q + "\n" + R1 + "\n" + S
+ "\n" + T + "\n" + RRdistance + "\n" + PRinterval + "\n" + QSdistance + "\n"
+ HeartRate + " "+ "\n" + "Amplitude of peaks:" + "\n" + Pamp + ";" + " " + Qamp + ";" + " " + Ramp + ";" + " " + Samp + ";" + " " + Tamp + ";");
我将使用 heartrate、pamp、printerval 和 qsdistance。如何将所有这些条件写在一个 if 语句中?
if (60 <= heartrate <= 100) && (0 <= pamp <= 0.25) && (0.12 <= printerval <= 0.20) && (0.04 <= qsdistance < 0.12)
如果所有这些条件都满足,那么它将显示 NORMAL。否则,异常。
我尝试将所有这些都放在一个 if 语句中,但它显示错误。我希望你能帮助我弄清楚如何做到这一点。谢谢!