Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Also its object oriented design so i need two codes one TipCalculatorFrame.java

ID: 3707644 • Letter: A

Question

Also its object oriented design so i need two codes one TipCalculatorFrame.java And second TipCalculatorProgram.java
Tip Calculator Program Create a graphical tip calculator program. The user should enter their bill amount into a text field and select the desired tip percentage using a slider. When the user presses the “Calculate Tip” button, the tip amount and total amount is displayed in separate labels. The program must also have “Reset” button. Your Tip Calculator’s window size should be no more than 300 pixels wide and 250 pixels tall. How your Tip Calculator must look:(see photo) • When the program first starts, the bill amount field should be empty, the slider should be set at 30, and the tip and total amount labels should display “Tip Amount:” and “Total Amount:”, respectively. • When the “Calculate Tip” button is pressed, the tip amount (bill amount * (slider’s value / 100)) and total amount (bill amount + tip amount) will be displayed in the in the appropriate label, rounded to two decimal places. (See photo • When the user presses the “Reset” button, the window will return to its original state (empty bill amount field, slider set to 30, tip amount and total amount labels set back to “Tip Amount:” and “Total Amount:” Additional Sample Input/Output see photos (see photo)
DO NOT USE A GUI/FORM DESIGNER TOOL TO CREATE THIS PROGRAM’S USER INTERFACE.    Also its object oriented design so i need two codes one TipCalculatorFrame.java And second TipCalculatorProgram.java
Tip Calculator Program Create a graphical tip calculator program. The user should enter their bill amount into a text field and select the desired tip percentage using a slider. When the user presses the “Calculate Tip” button, the tip amount and total amount is displayed in separate labels. The program must also have “Reset” button. Your Tip Calculator’s window size should be no more than 300 pixels wide and 250 pixels tall. How your Tip Calculator must look:(see photo) • When the program first starts, the bill amount field should be empty, the slider should be set at 30, and the tip and total amount labels should display “Tip Amount:” and “Total Amount:”, respectively. • When the “Calculate Tip” button is pressed, the tip amount (bill amount * (slider’s value / 100)) and total amount (bill amount + tip amount) will be displayed in the in the appropriate label, rounded to two decimal places. (See photo • When the user presses the “Reset” button, the window will return to its original state (empty bill amount field, slider set to 30, tip amount and total amount labels set back to “Tip Amount:” and “Total Amount:” Additional Sample Input/Output see photos (see photo)
DO NOT USE A GUI/FORM DESIGNER TOOL TO CREATE THIS PROGRAM’S USER INTERFACE.    r must look Tip Calculator Enter the bill amount Tip Percentage: 0 10 20 30 40 50 Tip Amount: Total Amount: Calculate Tip Reset ram first ctat

Explanation / Answer

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DecimalFormat;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JSlider;
import javax.swing.JTextField;
import java.awt.Font;
public class TipCalculator extends JFrame {

    private JButton butCalculate;
    private JButton butReset;
    private JLabel jLabel1;
    private JLabel jLabel2;
    private JLabel jLabel3;
    private JLabel lblTip;
    private JLabel lblTotal;
    private JSlider sldTip;
    private JTextField txtInput;
    public TipCalculator() {
    jLabel1 = new JLabel();
         txtInput = new JTextField();
         sldTip = new JSlider();
         jLabel2 = new JLabel();
         jLabel3 = new JLabel();
         butCalculate = new JButton();
         butReset = new JButton();
         lblTip = new JLabel();
         lblTotal = new JLabel();

      
         getContentPane().setLayout(null);

         jLabel1.setFont(new Font("Tahoma", 1, 12));
         jLabel1.setText("Enter Bill Amount");
         getContentPane().add(jLabel1);
         jLabel1.setBounds(68, 19, 108, 15);
         getContentPane().add(txtInput);
         txtInput.setBounds(210, 10, 105, 30);

         sldTip.setMajorTickSpacing(10);
         sldTip.setMaximum(50);
         sldTip.setMinorTickSpacing(2);
         sldTip.setPaintLabels(true);
         sldTip.setPaintTicks(true);
         sldTip.setValue(30);
         getContentPane().add(sldTip);
         sldTip.setBounds(89, 55, 200, 45);

         jLabel2.setFont(new Font("Tahoma", 1, 14));
         jLabel2.setText("Tip Amount: ");
         getContentPane().add(jLabel2);
         jLabel2.setBounds(68, 118, 90, 23);

         jLabel3.setFont(new Font("Tahoma", 1, 14));
         jLabel3.setText("Total Amount: ");
         getContentPane().add(jLabel3);
         jLabel3.setBounds(68, 171, 104, 17);

         butCalculate.setFont(new Font("Tahoma", 1, 14));
         butCalculate.setText("Calculate Tip");
         butCalculate.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent evt) {
                 butCalculateActionPerformed(evt);
             }
         });
         getContentPane().add(butCalculate);
         butCalculate.setBounds(101, 217, 130, 25);

         butReset.setFont(new Font("Tahoma", 1, 14));
         butReset.setText("Reset");
         butReset.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent evt) {
                 butResetActionPerformed(evt);
             }
         });
         getContentPane().add(butReset);
         butReset.setBounds(238, 217, 90, 25);

         lblTip.setFont(new Font("Tahoma", 1, 14));
         getContentPane().add(lblTip);
         lblTip.setBounds(200, 118, 82, 0);

         lblTotal.setFont(new Font("Tahoma", 1, 14));
         getContentPane().add(lblTotal);
         lblTotal.setBounds(227, 171, 82, 0);
    }

                        

    // Calculate tip button action handler
    private void butCalculateActionPerformed(ActionEvent evt) {                                            
        // TODO add your handling code here:
        lblTip.setBounds(200, 118, 82, 20);
        lblTotal.setBounds(227, 171, 82, 20);
        DecimalFormat df = new DecimalFormat("#.##");
        //Get user input
        double inpAmount = Double.parseDouble(txtInput.getText().trim());
        int tipPercent = sldTip.getValue();
        //Calculate tip amount
        double tipAmount = (inpAmount * tipPercent) / 100.0;
        lblTip.setText("$"+df.format(tipAmount));
        double totalAmount = tipAmount + inpAmount;
        lblTotal.setText("$"+df.format(totalAmount));
               
       
    }                                           

    //Reset button action handler
    private void butResetActionPerformed(ActionEvent evt) {                                        

        txtInput.setText("");
        lblTip.setText("");
        lblTotal.setText("");
        sldTip.setValue(30);
    }                                       

    public static void main(String args[]) {
       
       
             TipCalculator tc=   new TipCalculator();
             tc.setTitle("Tip Calculator");
             tc.setSize(400,300);
             tc.setVisible(true);
    }

                 }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote