Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA- This is the output that we are supposed to be getting- When I run my code, I am not getting the correct number of

JAVA- This is the output that we are supposed to be getting-

image text in transcribed

When I run my code, I am not getting the correct number of stars in the "score"column. Here is my code and my output:

import java.text.DecimalFormat; import java.text.Format; import java.util.Scanner; public class test { 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");

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;

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

if(respiratoryRate>=12 && respiratoryRate

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

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

if(BMI>=18.5 && BMI

if((systolicPressure>=90 && systolicPressure=60 && diastolicPressure

for(int i=0; i

} }

OUTPUT:

image text in transcribed

Sample Input/Output File inl 1.dat Smith 70 15 72 168 110 70 Oracle 70 0 62 130 110 70 Switch 59 15 70 175 110 81 Trinity 100 11 68 140 110 70 Morpheus 60 19 72 175 110 70 Cypher 80 18 82 176 110 85 Dozer 80 15 82 177 89 70 Dujour 70 15 62 0 110 70 Tank 80 15 70 174 110 70 Neo 101 15 72 175 110 59 Jones 110 19 69 220 110 55 Apoc 80 15 62 130 121 70 Execution Name Heart Rate Resp Rate Height Weight Smith 70 15 72 168 Invalid record 70 175 Switch 59 15 Trinity 100 11 68 140 175 Morpheus 60 19 72 Cypher 80 82 176 80 15 82 Dozer Invalid record Tank 80 15 70 174 175 101 15 72 Neo 110 19 69 220 Jones 130 80 15 62 Apoc BMI BP 22.8 10/70 25.1 110/81 21.3 10/70 23.7 10/70 18.4 10/85 18.5 89/70 110/70 25.0 23.7 10/59 32.5 10/55 23.8 121/70 Score

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

3rd Edition

0128012757, 978-0128012758

More Books

Students also viewed these Databases questions