GUI java..
have this program, ((it calculates the Active Metabolic Rate,and computes the amount of calories expended per day.))
the code is provided and all the job is ::
1-crate project and name it:: amr_al Then, create a package and name it:: com.ra_al.amr Then, create a class and name it: amr_al
2- edit the code ( if it necessary) and run it in IntelliJ ide.
3- zip the project file..
import java.awt.Color;_x000D_ import java.awt.Dimension;_x000D_ import java.awt.event.ActionEvent;_x000D_ import java.awt.event.ActionListener;_x000D_ import javax.swing.JButton;_x000D_ import javax.swing.JLabel;_x000D_ import javax.swing.JPanel;_x000D_ import javax.swing.JTextField;_x000D_ _x000D_ _x000D_ _x000D_ _x000D_ _x000D_ _x000D_ _x000D_ _x000D_ public class amrPanel_x000D_ extends JPanel_x000D_ {_x000D_ public int aLevel = 1200; public int delta = 175;_x000D_ _x000D_ public String aString = "Sedentary";_x000D_ _x000D_ public boolean female = true;_x000D_ private JLabel hiteLabel;_x000D_ private JLabel weightLabel;_x000D_ _x000D_ public amrPanel() {_x000D_ hiteLabel = new JLabel("Enter Height in inches (integer):");_x000D_ weightLabel = new JLabel("Enter Weight in pounds (integer): ");_x000D_ ageLabel = new JLabel("Enter Your Age in Years (integer): ");_x000D_ _x000D_ activityLabel = new JLabel("Sedentary");_x000D_ outputLabel = new JLabel("Your AMR is: ");_x000D_ amrLabel = new JLabel("");_x000D_ sexLabel = new JLabel(" ");_x000D_ sexOutLabel = new JLabel(" Female ");_x000D_ goLabel = new JLabel(" Calculate AMR! ");_x000D_ _x000D_ _x000D_ _x000D_ hiteField = new JTextField(5);_x000D_ hiteField.addActionListener(new amrPanel.hiteListener(null));_x000D_ _x000D_ weight = new JTextField(5);_x000D_ weight.addActionListener(new amrPanel.weightListener(null));_x000D_ _x000D_ ageField = new JTextField(5);_x000D_ ageField.addActionListener(new amrPanel.ageListener(null));_x000D_ _x000D_ _x000D_ _x000D_ inc = new JButton("Increment !");_x000D_ inc.addActionListener(new amrPanel.incButtonListener(null));_x000D_ _x000D_ dec = new JButton("Decrement !");_x000D_ dec.addActionListener(new amrPanel.decButtonListener(null));_x000D_ _x000D_ sex = new JButton("Your Sex (Click to Toggle)");_x000D_ sex.addActionListener(new amrPanel.sexButtonListener(null));_x000D_ _x000D_ go = new JButton("Calculate AMR!");_x000D_ go.addActionListener(new amrPanel.goButtonListener(null));_x000D_ _x000D_ add(hiteLabel);_x000D_ add(hiteField);_x000D_ _x000D_ _x000D_ _x000D_ add(weightLabel);_x000D_ add(weight);_x000D_ _x000D_ add(ageLabel);_x000D_ add(ageField);_x000D_ _x000D_ add(inc);_x000D_ add(activityLabel);_x000D_ add(dec);_x000D_ add(sex);_x000D_ add(sexLabel);_x000D_ add(sexOutLabel);_x000D_ add(go);_x000D_ _x000D_ _x000D_ _x000D_ add(outputLabel);_x000D_ add(amrLabel);_x000D_ _x000D_ setPreferredSize(new Dimension(310, 175));_x000D_ setBackground(new Color(67, 198, 219)); }_x000D_ _x000D_ private JLabel outputLabel;_x000D_ _x000D_ private class hiteListener implements ActionListener { private hiteListener() {}_x000D_ _x000D_ public void actionPerformed(ActionEvent event) { String text = hiteField.getText();_x000D_ hite = Integer.parseInt(text); } }_x000D_ _x000D_ private JLabel ageLabel;_x000D_ private JLabel amrLabel;_x000D_ _x000D_ private class ageListener implements ActionListener { private ageListener() {}_x000D_ public void actionPerformed(ActionEvent event) { String text = ageField.getText();_x000D_ age = Integer.parseInt(text); } }_x000D_ _x000D_ private JLabel activityLabel;_x000D_ private JLabel sexLabel;_x000D_ private JLabel sexOutLabel;_x000D_ private JLabel goLabel;_x000D_ private class weightListener implements ActionListener { private weightListener() {}_x000D_ public void actionPerformed(ActionEvent event) { String lbsText = weight.getText();_x000D_ lbs = Integer.parseInt(lbsText); } }_x000D_ _x000D_ private JTextField hiteField;_x000D_ private JTextField weight;_x000D_ private JTextField ageField;_x000D_ private JButton inc;_x000D_ public void incDecActivity(boolean more) { if ((more) && (aLevel != 1725)) {_x000D_ aLevel += delta;_x000D_ }_x000D_ if ((!more) && (aLevel != 1200)) {_x000D_ aLevel -= delta;_x000D_ }_x000D_ switch (aLevel) {_x000D_ case 1200: _x000D_ aString = "Sedentary";_x000D_ break;_x000D_ case 1375: _x000D_ aString = "Light Activity";_x000D_ break;_x000D_ case 1550: _x000D_ aString = "Moderate Activity";_x000D_ break;_x000D_ case 1725: _x000D_ aString = "High Activity";_x000D_ break;_x000D_ default: _x000D_ aString = "Sedentary-D"; } }_x000D_ _x000D_ private JButton dec;_x000D_ private JButton sex;_x000D_ _x000D_ private class incButtonListener implements ActionListener { private incButtonListener() {}_x000D_ _x000D_ public void actionPerformed(ActionEvent event) { incDecActivity(true);_x000D_ activityLabel.setText(aString); } }_x000D_ _x000D_ private JButton go;_x000D_ public int lbs;_x000D_ _x000D_ private class decButtonListener implements ActionListener { private decButtonListener() {}_x000D_ public void actionPerformed(ActionEvent event) { incDecActivity(false);_x000D_ activityLabel.setText(aString); } }_x000D_ _x000D_ public int hite;_x000D_ public int age;_x000D_ private class sexButtonListener implements ActionListener { private sexButtonListener() {}_x000D_ _x000D_ public void actionPerformed(ActionEvent event) { if (female) {_x000D_ female = false;_x000D_ sexOutLabel.setText("Male");_x000D_ } else {_x000D_ female = true;_x000D_ sexOutLabel.setText("Female");_x000D_ }_x000D_ }_x000D_ }_x000D_ _x000D_ public float BMR(int weight, int hite, int age) { float BMR;_x000D_ float BMR;_x000D_ if (female) {_x000D_ BMR = (float)(655.0D + 4.35D * weight + 4.7D * hite - 4.7D * age);_x000D_ } else {_x000D_ BMR = (float)(66.0D + 6.23D * weight + 12.7D * hite - 6.8D * age);_x000D_ }_x000D_ _x000D_ return BMR;_x000D_ }_x000D_ _x000D_ private class goButtonListener implements ActionListener { private goButtonListener() {}_x000D_ _x000D_ public void actionPerformed(ActionEvent event) { if ((lbs != 0) && (hite != 0) && (age != 0)) {_x000D_ float amr = BMR(lbs, hite, age) * aLevel / 1000.0F;_x000D_ amrLabel.setText(String.valueOf(amr));_x000D_ }_x000D_ }_x000D_ }_x000D_ }_x000D_ _x000D_ import javax.swing.JFrame;public class AMR
{
public AMR() {}
public static void main(String[] args)
{
JFrame frame = new JFrame(" AMR calculator");
frame.setDefaultCloseOperation(3);
amrPanel panel = new amrPanel();
frame.add(panel);
frame.setSize(650, 430);
frame.pack();
frame.setResizable(false);
frame.setVisible(true);
}
}
_x000D_
"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.
Discount Code: CIPD30
Click ORDER NOW..


