Question
Edit this Java code using printf INSTEAD of tabs. When using tabs, I get an output like this---- I also want to keep the method
Edit this Java code using printf INSTEAD of tabs. When using tabs, I get an output like this----
I also want to keep the method that validates the input data but I do NOT want it to display if an entry is valid, ONLY display if it is invalid. I need it to look exactly like the Execution output below----
import java.text.DecimalFormat; import java.text.Format; import java.util.Scanner;
public class test {
public static void main(String[] args) { Scanner scanner = new Scanner(System.in);
System.out.println("Name\tHeart Rate\tResp Rate\tHeight\tWeight\tBMI\tBP\t\tScore");
while (scanner.hasNext()) {
String name = scanner.next(); int heartRate = scanner.nextInt(); int respiratoryRate = scanner.nextInt(); int height = scanner.nextInt(); int weight = scanner.nextInt(); int systolicPressure = scanner.nextInt(); int diastolicPressure = scanner.nextInt(); double BMI = calculateBMI(height, weight);
if (isInputDataValid(heartRate, respiratoryRate, height, weight, systolicPressure, diastolicPressure)) { System.out.println("valid"); System.out.print(name + "\t\t"); int score = 1; if (heartRate >= 60 && heartRate = 12 && respiratoryRate
if (isInputDataValid(heartRate, respiratoryRate, height, weight, systolicPressure, diastolicPressure)) { System.out.println("valid"); System.out.print(name + "\t\t"); int score = 1; if (heartRate >= 60 && heartRate = 12 && respiratoryRate = 90 && systolicPressure = 60 && diastolicPressure
static boolean isInputDataValid(int heartRate, int respiratoryRate, int height, int weight, int systolicPressure, int diastolicPressure) { if (heartRate == 0 || respiratoryRate == 0 || height == 0 || weight == 0 || systolicPressure == 0 || diastolicPressure == 0) return false; else return true; }
static double calculateBMI(int height, int weight) { double BMI = (((double) weight) * 0.453592d) / ((((double) height) * 0.0254) * (((double) height) * 0.0254)); Format f = new DecimalFormat("##.##"); return Double.parseDouble(f.format(BMI)); } }
Trinity valid Morpheus valid Cypher valid Dozer valid Tank valid Neo valid Jones valid Apoc 100 80 80 80 101 110 80 60 11 68 19 18 82 15 82 15 70 15 72 19 69 15 140 72 174 175 220 130 21.286691 110/70 175 23.734004 110/70 18.507319 89/70 18.507319 89/70 24.966124 110/70 23.734004 110/55 32.487961 110/55 121/70 23.777048Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started