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

INTRO TO JAVA PROGRAMMING The cost to become a member of a fitness center is as

ID: 3722232 • Letter: I

Question

INTRO TO JAVA PROGRAMMING

The cost to become a member of a fitness center is as follows: (a) the Senior citizens discount is 30%; (b) if the membership is bought and paid for 12 or more months in advance, the discount is 15%; or (c) if more than 5 personal training sessions are purchased, the discount on each session is 20%. Write a menu driven program that determines the cost of a new membership.

Your program must contain a method that displays the general information about the fitness center and its charges, a method to get all the necessary information to determine the membership cost and a method to determine the membership cost.

Use appropriate parameters to pass information in and out of a method.

The first screen of your GUI will show the cost of membership and all of the discount options. Use JTextArea on page 811 for this part.

Membership Cost: $500

Training Sessions Cost: $100 per session

List the discounts here: A: Senior citizens discount is 30%, B) 15% discount if the membership is bought and paid for 12 or more months in advance, C) if more than 5 personal training sessions are purchased, the discount on each session is 20%.

Then you need to get the input from the user like on page 354, using JTextField for the input, Jlabel to describe what you want them to input and some buttons. (Calculate, Exit)

1. The user can choose 1 or 2 (Yes, No) for Senior or it can be a yes or no input.

2. Have the user enter number of months, or you can give them choices. 6, 12, 18 month options.

3. Have the user enter number of training sessions they wish to purchase.

4. Finally, when the user clicks on the Calculate button. You will show their membership cost.

PLEASE MAKE JAVA CODE SHORT AND EASY AND PLEASE ADD COMMENTS SO I CAN UNDERSTAND THE PROCESS

811 HTML file for this program contains the following c Additional GUI Components height "50"> Additional GUI Components The remainder of this chapter introduces GUI components in addi duced in Chapter 6. For the most part, these additional GUI compon same way as the ones introduced earlier. For example, you create using the operator new. If the program olcomponents are used in the Xample, you create an instance (or object) GUI onent, such as JTextField vide the associated method th omp needs to respond to an event occurring in a or JButton, you must add an event listener and at needs to be invoked, commonly called the event We will also illustrate the use of various method s of the class Graphics JTextArea The GUI programs in display a line of text. However, there are situations when the program must multiple lines of text. For example, an employee's address is shown in three or more lines. Because an object of the class JText cannot use an object of this class to display multiple lines of text. Java provides the class JTextArea to either collect multiple lines of input from the user or to display multiple lines of output. Using an object of this class, the user can type multiple lines of text, which are separated by pressing the Enter key. In Java, each line ends with the newline character 'n' previous chapters extensively used the class JTextField to display Field can display only one line of text, you The GUI part of the Student Grade Report programming example in Chapter 10, (available with the Additional Student Files at www.cengagebrain.com) uses a JTextArea to display multiple lines of text to show the various courses taken by a student and the student's grade for each course. This section discusses the capabilities of the class JTextArea in some detail. Both JTextField and JTextArea are derived from the class JTextComponent and as such, share many common methods. However, you cannot create an instance of the class JTextComponent because it is an abstract class. Table 12-8 1 constructors and methods of the class JTextArea of the

Explanation / Answer

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package membership.fee.calculator;


      


/**
*
* @author Nightshade
*/
public class Fee_calculator extends javax.swing.JFrame {

    /**
     * Creates new form Fee_calculator
     */
    public Fee_calculator() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                        
    private void initComponents() {

        SeniorCitizen = new javax.swing.ButtonGroup();
        MonthPackage = new javax.swing.ButtonGroup();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        Senior_Y = new javax.swing.JRadioButton();
        Senior_N = new javax.swing.JRadioButton();
        mt_6 = new javax.swing.JRadioButton();
        mt_12 = new javax.swing.JRadioButton();
        mt_18 = new javax.swing.JRadioButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        training_sessions = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        membership_cost = new javax.swing.JTextField();
        Calculate = new javax.swing.JButton();
        Exit = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTextArea2 = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jTextArea1.setText("Membership Cost: $500 Training Sessions Cost: $100 per session");
        jScrollPane1.setViewportView(jTextArea1);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel1.setText("List Of Discounts here :");

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel2.setText("Membership Fee :");

        SeniorCitizen.add(Senior_Y);
        Senior_Y.setText("YES");

        SeniorCitizen.add(Senior_N);
        Senior_N.setText("NO");

        MonthPackage.add(mt_6);
        mt_6.setText("6");

        MonthPackage.add(mt_12);
        mt_12.setText("12");

        MonthPackage.add(mt_18);
        mt_18.setText("18");

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel3.setText("Membership Duration :");

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel4.setText("Senior Citizen :");

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel5.setText("Number of Training Sessions :");

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel6.setText("Membership Cost :");

        membership_cost.setEditable(false);
        membership_cost.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                membership_costActionPerformed(evt);
            }
        });

        Calculate.setText("Calculate");
        Calculate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CalculateActionPerformed(evt);
            }
        });

        Exit.setText("Exit");

        jTextArea2.setColumns(20);
        jTextArea2.setRows(5);
        jTextArea2.setText("A) Senior citizens discount is 30% B) 15% discount if the membership is bought    and paid for 12 or more months in advance, C) If more than 5 personal training sessions    are purchased, the discount on each session is 20%");
        jScrollPane3.setViewportView(jTextArea2);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(Calculate)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel5)
                                .addComponent(jLabel6)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(training_sessions)
                            .addComponent(membership_cost)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(Exit)
                                .addGap(0, 0, Short.MAX_VALUE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane3)
                            .addComponent(jScrollPane1)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(mt_6)
                                    .addComponent(mt_12)
                                    .addComponent(mt_18)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabel2)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel3)
                                        .addGap(61, 61, 61)
                                        .addComponent(jLabel4)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(Senior_Y, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(Senior_N, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .addGap(0, 68, Short.MAX_VALUE)))
                        .addContainerGap())))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(mt_6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(mt_12))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(Senior_Y)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Senior_N)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(mt_18)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(training_sessions, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(membership_cost, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Calculate)
                    .addComponent(Exit))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        Senior_Y.setActionCommand("YES");
        Senior_N.setActionCommand("NO");
        mt_6.setActionCommand("6");
        mt_12.setActionCommand("12");
        mt_18.setActionCommand("18");

        pack();
    }// </editor-fold>                      

    private void CalculateActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
      
        String s_c;
        int mc = 500,tsc = 100;
        double ttsc = 0.0,tc,disc,dp = 0.0;
      
      
        s_c = SeniorCitizen.getSelection().getActionCommand();
        String m = MonthPackage.getSelection().getActionCommand();
        int mth = Integer.parseInt(m);
        int ts = Integer.parseInt(training_sessions.getText());
      
        String s = evt.getActionCommand();
        if(s.equalsIgnoreCase("Calculate"))
        {
            if(s_c.equalsIgnoreCase("YES"))
            {
                dp = 0.30;
                if(mth >= 12)
                    dp +=0.15;
            }
            else
            {
                if(mth >= 12)
                    dp +=0.15;
            }
            if(ts > 5)
            {
                ttsc = tsc*ts - 0.20*tsc*ts;
            }
            tc = mc + ttsc;
            disc = dp*tc;
            tc -= disc;
            membership_cost.setText(tc+"");
        }
      
        else if(s.equalsIgnoreCase("Exit"))
        {
            System.exit(0);
        }
      
    }                                       

    private void membership_costActionPerformed(java.awt.event.ActionEvent evt) {                                              
        // TODO add your handling code here:
    }                                             

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Fee_calculator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Fee_calculator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Fee_calculator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Fee_calculator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Fee_calculator().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                   
    private javax.swing.JButton Calculate;
    private javax.swing.JButton Exit;
    private javax.swing.ButtonGroup MonthPackage;
    private javax.swing.ButtonGroup SeniorCitizen;
    private javax.swing.JRadioButton Senior_N;
    private javax.swing.JRadioButton Senior_Y;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextArea jTextArea2;
    private javax.swing.JTextField membership_cost;
    private javax.swing.JRadioButton mt_12;
    private javax.swing.JRadioButton mt_18;
    private javax.swing.JRadioButton mt_6;
    private javax.swing.JTextField training_sessions;
    // End of variables declaration                 
}

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