Question: Create a basic flowchart for the following Java code--- import java.text.DecimalFormat; import java.text.Format; import java.util.Scanner; public class HealthCheck { public static void main(String[] args) {

Create a basic flowchart for the following Java code---

import java.text.DecimalFormat; import java.text.Format; import java.util.Scanner; public class HealthCheck { public static void main(String[] args) { DecimalFormat f = new DecimalFormat("##.0"); Scanner reader = new Scanner(System.in);

System.out.printf("%10s %15s %12s %8s %8s %8s %9s %8s %n", "Name", "Heart Rate", "Resp Rate", "Height", "Weight", "BMI", "BP", "Score"); //Checking to see if other records exist while(reader.hasNext()){

String name = reader.next(); int heartRate = reader.nextInt(); int respiratoryRate = reader.nextInt(); int height = reader.nextInt(); int weight = reader.nextInt(); int systolicPressure = reader.nextInt(); int diastolicPressure = reader.nextInt(); double BMI = calculateBMI(height, weight); int score = 1;

//Validating record if(heartRate == 0 ||respiratoryRate == 0 ||height == 0 ||weight == 0 ||systolicPressure == 0 || diastolicPressure== 0){ System.out.print("Invalid record!"); } else{ System.out.printf("%10s", name);

if(heartRate>=60 && heartRate<=100){ score++; System.out.printf("%16s", heartRate); } else{ System.out.printf("%16s", "!!" +heartRate); }

if(respiratoryRate>=12 && respiratoryRate<=18){ score++; System.out.printf("%13s", respiratoryRate);

} else{ System.out.printf("%13s", "!!" +respiratoryRate); }

System.out.printf("%9s", height); System.out.printf("%9s", weight);

if(BMI>=18.5 && BMI <=25.0){ System.out.printf("%9s", f.format(BMI)); } else{ System.out.printf("%9s", "!!" + f.format(BMI)); }

if((systolicPressure>=90 && systolicPressure<=120) && (diastolicPressure>=60 && diastolicPressure<=80)){ score++; System.out.printf("%11s", systolicPressure + "/" + diastolicPressure + "\t"); } else{ System.out.printf("%11s", "!!" + systolicPressure + "/" + diastolicPressure + "\t"); }

//Determining overall health score for(int i=0; i<=score; i++) System.out.print("*"); } System.out.println(); } } //Method to determine BMI public static double calculateBMI(int height, int weight) { double BMI = (((double) weight) * 0.453592d) / ((((double) height) * 0.0254) * (((double) height) * 0.0254)); return (BMI);

} }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!