In: Computer Science
Create in Java a program that will prompt the user to enter a weight for a patient in kilograms and that calculates both bolus and infusion rates based on weight of patient in an interactive GUI application, label it AMI Calculator. The patients weight will be the only entry from the user. Use 3999 as a standard for calculating BOLUS: To calculate the BOLUS you will multiply 60 times the weight of the patient for a total number. IF the total number is less than 3999, then the BOLUS is the total number else it is 4000 Use 19.99 as a standard for calculating Maintenance infusion: To calculate the Maintenance infusion you will multiply 12 times the weight divided by 50 for a total number. IF the total number is less than 19.99 then the Maintenance infusion is the total number else it is 20 Use 50 and 100 KG as your test weight.
Sample output:
Weight in kg: 50.00 KG
BOLUS 3000 units
Maintenance infusion of 12 ml/hour.
Weight in kg: 100.00 KG
BOLUS 4000 units
Maintenance infusion of 20 ml/hour.
1. AMICalculator.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class AMICalculator {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Weight of patient");
int weight = Integer.parseInt(br.readLine());
int totalNumber = 60 * weight;
int BOLUS = 3999;
float MAINTAIN_FUSION = 19.99F;
if (totalNumber < BOLUS){
BOLUS = totalNumber;
}else{
BOLUS = 4000;
}
totalNumber = (12 * weight) / 50;
if (totalNumber < 19.99){
MAINTAIN_FUSION = totalNumber;
}else{
MAINTAIN_FUSION = 20;
}
System.out.println("Weight in kg: " + weight);
System.out.println("BOLUS: " + BOLUS + " units");
System.out.println("Maintenance infusion: " + MAINTAIN_FUSION + " ml/hour");
}
}
The output is attached below:-