Untitled
unknown
plain_text
a year ago
7.3 kB
4
Indexable
import javax.swing.JOptionPane;
public class BloodAnalysis {
public static void main(String[] args) {
// Input section using JOptionPane
String Gender = JOptionPane.showInputDialog("Enter Gender (M/F):");
double Glucose = Double.parseDouble(JOptionPane.showInputDialog("Enter Glucose Level:"));
double BloodUreaNitrogen = Double.parseDouble(JOptionPane.showInputDialog("Enter Blood Urea Nitrogen Level:"));
double SerumUricAcid = Double.parseDouble(JOptionPane.showInputDialog("Enter Serum Uric Acid Level:"));
double Creatinine = Double.parseDouble(JOptionPane.showInputDialog("Enter Creatinine Level:"));
double Cholesterol = Double.parseDouble(JOptionPane.showInputDialog("Enter Cholesterol Level:"));
double HDL = Double.parseDouble(JOptionPane.showInputDialog("Enter HDL Level:"));
double LDL = Double.parseDouble(JOptionPane.showInputDialog("Enter LDL Level:"));
double Triglycerides = Double.parseDouble(JOptionPane.showInputDialog("Enter Triglycerides Level:"));
String glucose = "";
String bloodUreaNitrogen = "";
String serumUricAcid = "";
String creatinine = "";
String cholesterol = "";
String hdl = "";
String ldl = "";
String triglycerides = "";
boolean AllNormal = true;
boolean GlucoseLevel = false;
boolean CholesterolLevel = false;
boolean TriglyceridesLevel = false;
if (Glucose >= 3.8 && Glucose <= 5.8) {
glucose = "Your GLUCOSE result is " + Glucose + " mmoll/L NORMAL.\n";
} else {
AllNormal = false;
GlucoseLevel = true;
glucose = "Your GLUCOSE level is " + Glucose + " mmol/L HIGHER THAN NORMAL. You should be in a low carb diet.\n";
}
if (BloodUreaNitrogen >= 5.35 && BloodUreaNitrogen <= 16.07) {
bloodUreaNitrogen = "Your BLOOD UREA NITROGEN result is " + BloodUreaNitrogen +" mmol/L NORMAL.\n";
} else {
AllNormal = false;
bloodUreaNitrogen = "Your BLOOD UREA NITROGEN result is" + BloodUreaNitrogen +" mmol/L NOT NORMAL.\n";
}
if (Cholesterol >= 3.87 && Cholesterol <= 5.68) {
cholesterol = "Your CHOLESTEROL result is " + Cholesterol + " mmol/L NORMAL.\n";
} else {
AllNormal = false;
CholesterolLevel = true;
cholesterol = "Your CHOLESTEROL level is " + Cholesterol + " mmol/L HIGHER THAN NORMAL. You should be in a low fat diet.\n";
}
if (LDL < 3.9) {
ldl = "Your LDL result is " + LDL + " mmol/L NORMAL.\n";
} else {
AllNormal = false;
ldl = "Your LDL is " + LDL + " mmol/L HIGHER THAN NORMAL.\n";
}
switch (Gender.toUpperCase()) {
case "M" -> {
if (SerumUricAcid >= 0.14 && SerumUricAcid <= 0.35) {
serumUricAcid = "Your SERUM URIC ACID result is" + SerumUricAcid + " mmol/L NORMAL.\n";
} else {
AllNormal = false;
serumUricAcid = "Your SERUM URIC ACID level is " + SerumUricAcid + " mmol/L HIGHER THAN NORMAL. You should avoid foods that are high in purine and fat.\n";
}
}
case "F" -> {
if (SerumUricAcid >= 0.20 && SerumUricAcid <= 0.41) {
serumUricAcid = "Your SERUM URIC ACID result is" + SerumUricAcid + " mmol/L NORMAL.\n";
} else {
AllNormal = false;
serumUricAcid = "Your SERUM URIC ACID level is " + SerumUricAcid + " mmol/L higher than normal. You should avoid foods that are high in purine and fat.\n";
}
}
}
switch (Gender.toUpperCase()) {
case "M" -> {
if (Creatinine >= 62 && Creatinine <= 106) {
creatinine = "Your CREATININE result is" + Creatinine + " umol/L NORMAL.\n";
} else {
AllNormal = false;
creatinine = "Your CREATININE level is " + Creatinine + " umol/L higher than normal. You should avoid caffeine, alcohol, carbonated drinks, and salty foods.\n";
}
}
case "F" -> {
if (Creatinine >= 53 && Creatinine <= 115) {
creatinine = "Your CREATININE result is" + Creatinine + " umol/L NORMAL.\n";
} else {
AllNormal = false;
creatinine = "Your CREATININE level is " + Creatinine + " umol/L HIGHER THAN NORMAL. You should avoid caffeine, alcohol, carbonated drinks, and salty foods.\n";
}
}
}
switch (Gender.toUpperCase()) {
case "M" -> {
if (HDL >= 1.09 && HDL <= 2.28) {
hdl = "Your HDL result is" + HDL + " mmol/L NORMAL.\n";
} else {
AllNormal = false;
hdl = "Your HDL is " + HDL + " mmol/L HIGHER THAN NORMAL.\n";
}
}
case "F" -> {
if (HDL >= 0.90 && HDL <= 2.06) {
hdl = "Your HDL result is" + HDL + " mmol/L NORMAL.\n";
} else {
AllNormal = false;
hdl = "Your HDL is " + HDL + " mmol/L HIGHER THAN NORMAL.\n";
}
}
}
switch (Gender.toUpperCase()) {
case "M" -> {
if (Triglycerides >= 0.45 && Triglycerides <= 1.58) {
triglycerides = "Your TRIGLYCERIDES result is" + Triglycerides + " mmol/L NORMAL.\n";
} else {
AllNormal = false;
TriglyceridesLevel = true;
triglycerides = "Your TRIGLYCERIDES level is " + Triglycerides + " mmol/L HIGHER THAN NORMAL. You should avoid sugary and starchy foods.\n";
}
}
case "F" -> {
if (Triglycerides >= 0.57 && Triglycerides <= 1.86) {
triglycerides = "Your TRIGLYCERIDES result is" + Triglycerides + " mmol/L NORMAL.\n";
} else {
AllNormal = false;
TriglyceridesLevel = true;
triglycerides = "Your TRIGLYCERIDES level is " + Triglycerides + " mmol/L higher than normal. You should avoid sugary and starchy foods.\n";
}
}
}
if (GlucoseLevel && CholesterolLevel && TriglyceridesLevel) {
JOptionPane.showMessageDialog(null, "Your Glucose, Cholesterol, and Triglycerides levels are high. You should be in a low carb and low fat diet. You should also take Telmisartan and Atrovastatin.\n" + bloodUreaNitrogen + serumUricAcid + creatinine + hdl + ldl);
} else if (AllNormal) {
JOptionPane.showMessageDialog(null, "Your Blood Chem Result is NORMAL. You are generally HEALTHY.");
} else {
JOptionPane.showMessageDialog(null, glucose + bloodUreaNitrogen + serumUricAcid + creatinine + cholesterol + hdl + ldl + triglycerides);
}
}
}Editor is loading...
Leave a Comment