Question

In: Computer Science

Create in java an interactive GUI application program that will prompt the user to use one...

Create in java an interactive GUI application program that will prompt the user to use one of three calculators, label project name MEDCALC. You can use any color you want for your background other than grey. Be sure to label main java box with “MEDCALC” and include text of “For use only by students”

On all three calculators create an alert and signature area for each user. The alert should be something like All calculations must be confirmed by user before use.” The user will need to sign acknowledging the alert before they are allowed to move on to use the calculator; at this point your program should also write to a file on the user’s local computer, capturing data of date and name signed (this can be a text file or excel file). Again, User should not be able to use any of the calculators if they do not provide name.

Calculator one is CALC1, Calculator two is CALC2, Calculator three is CALC3. (CALC3 will be created later)

Calculator one: Be sure to label “CALC1”

Prompt user to enter a weight for a patient in kilograms. Calculate both bolus and infusion rates based on weight of patient. The patient’s 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.

Two sample outputs: (user should see this data displayed)

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

Calculator two: Be sure to label “CALC2”

Prompt user to enter a weight for a patient in kilograms. Calculate infusion rate based on weight of patient.

To calculate the infusion rate you will multiply 12 times the weight divided by 50 for a total number. The end result will need to round up or down the whole number.

Example:

12 times 55 divided by 50 equals 13.2 should round down to 13 for
55 KG
13 ml/Hour

12 times 57 divided by 50 equals 13.68 should round up to 14 for
55 KG
14 mL/hour

Use 55 and 57 kg as your test weight.

Two sample outputs: (user should see this data displayed)

Weight in kg: 55 kg
Infusion of 13 ml/hour

Weight in kg: 57 kg
Infusion of 14 ml/hour

Solutions

Expert Solution

package GUI;

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

// Defines a class MEDCALC

public class MEDCALC

{

// Declares container and component objects

private JFrame jf;

private JPanel jp1, jp2, mainP;

private JTextArea result;

private JButton CALC1, CALC2;

// Default constructor definition

MEDCALC()

{

// Creates a frame

jf = new JFrame("MEDCALC");

// Creates panels

jp1 = new JPanel();

jp2 = new JPanel();

mainP = new JPanel();

// Creates text area

result = new JTextArea(4, 20);

// Creates buttons

CALC1 = new JButton("CALC1");

CALC2 = new JButton("CALC2");

// Adds the buttons to panel 1

jp1.add(CALC1);

jp1.add(CALC2);

// Adds the text area to panel 2

jp2.add(result);

// Adds the panels to main panel

mainP.add(jp1);

mainP.add(jp2);

// Sets the layout to grid layout with 2 row and 1 column

mainP.setLayout(new GridLayout(2, 1));

// Adds the main panel to frame

jf.add(mainP);

// Sets the background color of the panels

jp1.setBackground(Color.RED);

jp2.setBackground(Color.BLUE);

// Sets the frame visible property to true

jf.setVisible(true);

// Set the size of the frame to width 400 and height 200

jf.setLocationRelativeTo(null);

jf.pack();

// Registers action listener to CALC1 button using anonymous class

CALC1.addActionListener(new ActionListener()

{

// Overrides the actionPerformed() method of ActionListener interface

public void actionPerformed(ActionEvent ae)

{

int bolus;

int infusion;

// Accepts weight from the user

int weight = Integer.parseInt(JOptionPane.showInputDialog(jf,

"Enter a weight for a patient in kilograms: "));

// Calculates total number for bolus

int totalNumber = weight * 60;

// Checks if total number is less than 3999

if(totalNumber < 3999)

// Assign total number to bolus

bolus = totalNumber;

// Otherwise assign 4000 to bolus

else

bolus = 4000;

// Calculates total number for infusion

totalNumber = weight * 12 / 50;

// Checks if total number is less than 19.99

if(totalNumber < 19.99)

// Assign total number to infusion

infusion = totalNumber;

// Otherwise assign 20 to infusion

else

infusion = 20;

// Sets the result to text area

result.setText(" Weight in kg: " + weight + " kg"

+ "\n BOLUS " + bolus + " units"

+ "\n Maintenance infusion of " + infusion + " ml/hour");

}// End of method

});// End of anonymous class

// Registers action listener to CALC2 button using anonymous class

CALC2.addActionListener(new ActionListener()

{

// Overrides the actionPerformed() method of ActionListener interface

public void actionPerformed(ActionEvent ae)

{

// Accepts weight from the user

int weight = Integer.parseInt(JOptionPane.showInputDialog(jf,

"Enter a weight for a patient in kilograms: "));

// Calculates the infusion and rounds the result

int infusion = (int)Math.round(weight * 12.0 / 50.0);

// Sets the result to text area

result.setText(" Weight in kg: " + weight + " kg"

+ "\n Maintenance infusion of " + infusion + " ml/hour");

}// End of method

});// End of anonymous class

}// End of default constructor

// main method definition

public static void main(String ss[])

{

// Calls the default constructor

new MEDCALC();

}// End of main method

}// End of class

Sample Output:


Related Solutions

Create a java Swing GUI application that presents the user with a “fortune”. Create a java...
Create a java Swing GUI application that presents the user with a “fortune”. Create a java Swing GUI application in a new Netbeans project called FortuneTeller. Your project will have a FortuneTellerFrame.java class (which inherits from JFrame) and a java main class: FortuneTellerViewer.java. Your application should have and use the following components: Top panel: A JLabel with text “Fortune Teller” (or something similar!) and an ImageIcon. Find an appropriate non-commercial Fortune Teller image for your ImageIcon. (The JLabel has a...
Use the below info to create a java program A GUI interface to ensure a user...
Use the below info to create a java program A GUI interface to ensure a user is old enough to play a game. Properly formatted prompts to input name, address, phone number, and age. Remember that name, address, phone number, etc. can be broken out in additional fields. Refer to the tutorial from this week’s Reading Assignment Multiple vs. Single Field Capture for Phone Number Form Input for help with this. Instructions to ensure that the information is displayed back...
Create in Java a program that will prompt the user to enter aweight for a...
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...
Create in java a program that will prompt the user to enter a weight for a...
Create in java a program that will prompt the user to enter a weight for a patient in kilograms and that calculates infusion rates based on weight of patient in an interactive GUI application, label it HEPCALC. The patients’ weight will be the only entry from the user. To calculate the infusion rate you will multiply 12 times the weight divided by 50 for a total number. The end result will need to round up or down the whole number....
Create a Java application that will prompt the user for the first name of 6 friends...
Create a Java application that will prompt the user for the first name of 6 friends in any order and store them in an array. First, output the array unsorted. Next, sort the array of friends and then output the sorted array to the screen. Be sure to clearly label the output. See the example program input and output shown below. It does not have to be exactly as shown in the example, however it gives you an idea of...
5) Create the following in a Java program Create a scanner Prompt the user to enter...
5) Create the following in a Java program Create a scanner Prompt the user to enter the name where the box of mail is shipping from and create the variable and relate to scanner Prompt the user to enter the name of destination where the box of mail will be shipped and create the variable and relate to scanner Prompt the user to enter the weight of the package and create variable to relate to scanner Calculate cost of shipping...
6) Create the following in a Java Program: Create payroll system Prompt the user to enter...
6) Create the following in a Java Program: Create payroll system Prompt the user to enter payroll information Employee name and create variable for scanner Hours worked Hourly pay rate Federal tax rate State tax rate Declare variable doubles for gross pay, federal, state and total deduction Display payroll statement example: Name of employee Hours worked Hourly pay rate Gross pay which is equal hours worked multiply hourly pay rate Federal withholding which is equal of gross pay multiply federal...
Create a program that will prompt for user information for a Web site. Use a structure...
Create a program that will prompt for user information for a Web site. Use a structure to store the data. The structure will need to include the following items: First Name - string Last Name - string Full Name - string Birth Date   - int (assume format yyyymmdd) IsLeasingAutomobile - bool yearlySalary - float Create a single structure from the items listed above. Prompt for all items except "Full Name" and load the input directly into a variable based on...
Java Please comment code Create an Interactive JavaFX Application Create an application with the following controls:...
Java Please comment code Create an Interactive JavaFX Application Create an application with the following controls: A Label control with the following text displayed: "First Number:" A Label control with the following text displayed: "Second Number:" An empty TextField control beside the First Number label. An empty TextField control beside the Second Number label. Five buttons: Button 1 labeled + Button 2 labeled - Button 3 labeled * Button 4 labeled / Button 5 labeled = An empty Label control...
Using Java create an interactive (the user should be able to input the values) Java Application to process your utility bill for at-least 6 months.
Java ProgrammingAssignment 7.1 (25 points)Using Java create an interactive (the user should be able to input the values) Java Application to process your utility bill for at-least 6 months. Use Class-Object methodology and use single dimensional arrays in your application. Write detailed comments in your program. You should have a two classes (for example, MontlyBill.java & MontlyBillTest.java). You can also be creative and create your “own problem scenario” and come up with your “solution”.Assignment 7.2 (25 points)Use the same program...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT