Akash is tasked with developing a program that calculates and categorizes blood pressure based on the given systolic and diastolic readings. The program should use the following classifications:Low Blood Pressure: Systolic < 90 mm Hg or Diastolic < 60 mm HgNormal Blood Pressure: Systolic ≤ 120 mm Hg and Diastolic ≤ 80 mm HgPrehypertension: Systolic ≤ 140 mm Hg and Diastolic ≤ 90 mm HgStage 1 Hypertension: Systolic ≤ 160 mm Hg and Diastolic ≤ 100 mm HgStage 2 Hypertension: OtherwiseWrite a program to assist Akash in computing and classifying blood pressure levels based on input readings. The program should use a 'switch-case' to deliver a tailored blood pressure category.
Question
Akash is tasked with developing a program that calculates and categorizes blood pressure based on the given systolic and diastolic readings. The program should use the following classifications:Low Blood Pressure: Systolic < 90 mm Hg or Diastolic < 60 mm HgNormal Blood Pressure: Systolic ≤ 120 mm Hg and Diastolic ≤ 80 mm HgPrehypertension: Systolic ≤ 140 mm Hg and Diastolic ≤ 90 mm HgStage 1 Hypertension: Systolic ≤ 160 mm Hg and Diastolic ≤ 100 mm HgStage 2 Hypertension: OtherwiseWrite a program to assist Akash in computing and classifying blood pressure levels based on input readings. The program should use a 'switch-case' to deliver a tailored blood pressure category.
Solution
Sure, here is a simple program in Java that uses a 'switch-case' statement to classify blood pressure levels. However, please note that 'switch-case' is not the best choice for this task as it does not handle ranges well. It is better to use 'if-else' statements for this task. But as per your request, I will provide a solution using 'switch-case'.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter systolic reading:");
int systolic = scanner.nextInt();
System.out.println("Enter diastolic reading:");
int diastolic = scanner.nextInt();
String category = "";
if (systolic < 90 || diastolic < 60) {
category = "Low Blood Pressure";
} else if (systolic <= 120 && diastolic <= 80) {
category = "Normal Blood Pressure";
} else if (systolic <= 140 && diastolic <= 90) {
category = "Prehypertension";
} else if (systolic <= 160 && diastolic <= 100) {
category = "Stage 1 Hypertension";
} else {
category = "Stage 2 Hypertension";
}
switch (category) {
case "Low Blood Pressure":
System.out.println("You have Low Blood Pressure");
break;
case "Normal Blood Pressure":
System.out.println("You have Normal Blood Pressure");
break;
case "Prehypertension":
System.out.println("You have Prehypertension");
break;
case "Stage 1 Hypertension":
System.out.println("You have Stage 1 Hypertension");
break;
default:
System.out.println("You have Stage 2 Hypertension");
break;
}
}
}
This program first takes the systolic and diastolic readings as input. Then it checks which category the readings fall into and assigns the category to a string variable. Finally, it uses a 'switch-case' statement to print out the blood pressure category.
Similar Questions
Which of the following is a good indicator for a program that aims to decrease blood pressure in Stage 1 and Stage 2 hypertension patients?The percentage of patients having stage I and II hypertension received medicinesThe proportion of patients enrolled who are retained at 12 months and are happy with their careThe mean systolic blood pressure of patients having stage I and II hypertension patientsThe proportion of patients having stage I and II hypertension among all patients
What do you call this illness that is characterized by a condition in which pressure in blood vesselshigher than it should be?a. Hyperglycemia c. Hypertensionb. Hypernatremia d. Hyperkalemia19. Blood pressure is measured using two numbers: The first number is called systolic pressure while theother is diastolic pressure. Blood pressure measures the pressure of blood pushing against the walls of yourarteries when your heart beats. What is being measured when we measure the diastolic pressure?a. Contraction of the heart c. Relaxation of the heartb. Number of skipped beats of the heart d. Number of beats of the heart20. What is the normal blood pressure of a normal adult individual?a. 140/100 c. 120/80b. 130/80 d. 180/120
Which of the following blood pressures is considered prehypertension?Multiple Choice130 mm Hg over 85 mm Hg118 mm Hg over 82 mg Hg142 mm Hg over 95 mm Hg145 mm Hg over 105 mm Hg
The ... Karotkoff sound represents the systolic blood pressure value and the transition from the ... to the ... Karotkoff sounds represent the diastolic blood pressure value.
Implement a program that utilizes multiple inheritance to assess John's health. Create classes BMI (with weight and height as attributes) and BloodPressure (with systolic and diastolic pressures as attributes) to compute health metrics.In the Health class, inherit from both classes BMI and BloodPressure to provide an integrated health assessment. Input John's weight, height, systolic, and diastolic values and determine his health status.Note: BMI = Weight / (height * height)Input format :The first line consists of a positive double value representing the individual's weight in kilograms.The second consists of a positive double value representing the height in meters.The third line consists of a positive integer value representing the systolic blood pressure measurement.The fourth line consists of a positive integer value representing the diastolic blood pressure measurement.Output format :The output displays the overall health status, which can be one of the following:"Underweight with Low Blood Pressure" when BMI < 18.5, systolic < 90 and diastolic < 60."Healthy Weight with Normal Blood Pressure" when BMI is between 18.5 and 24.9 (exclusive), systolic is between 90 and 120, and diastolic is between 60 and 80."Overweight with High Blood Pressure" when BMI is between 25.0 and 29.9 (exclusive) and systolic and diastolic are both higher than 120 and 80, respectively."Health Risk Undefined" for any other conditions.Refer to the sample output for the formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:10.0 ≤ Weight ≤ 200.00.5 ≤ Height ≤ 2.570 ≤ Systolic blood pressure ≤ 20040 ≤ Diastolic blood pressure ≤ 150Sample test cases :Input 1 :48.01.658050Output 1 :Underweight with Low Blood PressureInput 2 :70.01.7511575Output 2 :Healthy Weight with Normal Blood PressureInput 3 :90.01.7013590Output 3 :Health Risk Undefined
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.