Question: Please submit your final project: Your design specifications must meet the followingRequirements: 1 . Arrays 2 . Methods with parameters 3 . Input or output

Please submit your final project: Your design specifications must meet the followingRequirements:1. Arrays2. Methods with parameters3. Input or output files4. GUI or menuimport javax.swing.*;import java.awt.*;import java.awt.event.*;public class RectangleProgram extends JFrame { private JLabel lengthL, widthL, areaL, perimeterL; private JTextField lengthTF, widthTF, areaTF, perimeterTF; private JButton calculateB, clearB, exitB; private CalculateButtonHandler cbHandler; private ExitButtonHandler ebHandler; private ClearButtonHandler clrHandler; private static final int WIDTH =400; private static final int HEIGHT =400; public RectangleProgram(){// Create the four labels lengthL = new JLabel("Enter the length: ", SwingConstants.RIGHT); widthL = new JLabel("Enter the width: ", SwingConstants.RIGHT); areaL = new JLabel("Area: ", SwingConstants.RIGHT); perimeterL = new JLabel("Perimeter: ", SwingConstants.RIGHT); // Create the four text fields lengthTF = new JTextField(10); widthTF = new JTextField(10); areaTF = new JTextField(10); perimeterTF = new JTextField(10); // Create Calculate Button calculateB = new JButton("Calculate"); cbHandler = new CalculateButtonHandler(); calculateB.addActionListener(cbHandler); // Create Clear Button clearB = new JButton("Clear"); clrHandler = new ClearButtonHandler(); clearB.addActionListener(clrHandler); // Create Exit Button exitB = new JButton("Exit"); ebHandler = new ExitButtonHandler(); exitB.addActionListener(ebHandler); // Set the title of the window setTitle("Area and Perimeter of a Rectangle"); // Get the container Container pane = getContentPane(); // Set the layout pane.setLayout(new GridLayout(6,2)); // Place the components in the pane pane.add(lengthL); pane.add(lengthTF); pane.add(widthL); pane.add(widthTF); pane.add(areaL); pane.add(areaTF); pane.add(perimeterL); pane.add(perimeterTF); pane.add(calculateB); pane.add(exitB); pane.add(clearB); // Set the size of the window and display it setSize(WIDTH, HEIGHT); setVisible(true); setDefaultCloseOperation(EXIT_ON_CLOSE); } private class CalculateButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e){ double width, length, area, perimeter; length = Double.parseDouble(lengthTF.getText()); width = Double.parseDouble(widthTF.getText()); area = length * width; perimeter =2*(length + width); areaTF.setText(""+ area); perimeterTF.setText(""+ perimeter); }} private class ClearButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e){ lengthTF.setText(""); widthTF.setText(""); areaTF.setText(""); perimeterTF.setText(""); }} private class ExitButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e){ System.exit(0); }} public static void main(String[] args){ RectangleProgram rectObject = new RectangleProgram(); }}import javax.swing.*;import java.awt.*;import java.awt.event.*;public class CalcPayGui extends JFrame { private JLabel nameLabel, rateLabel, hoursLabel, deductLabel, grossLabel, netLabel; private JTextField nameTF, rateTF, hoursTF, deductTF, grossTF, netTF; private JButton calculateB, clearB, exitB; private CalculateButtonHandler cbHandler; private ExitButtonHandler ebHandler; private ClearButtonHandler clrHandler; public CalcPayGui(){ setTitle("Calculate Payroll"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); nameLabel = new JLabel("Name:"); rateLabel = new JLabel("Hourly Rate:"); hoursLabel = new JLabel("Hours Worked:"); deductLabel = new JLabel("Deduct:"); grossLabel = new JLabel("Gross Pay:"); netLabel = new JLabel("Net Pay:"); nameTF = new JTextField(20); rateTF = new JTextField(20); hoursTF = new JTextField(20); deductTF = new JTextField(20); grossTF = new JTextField(20); netTF = new JTextField(20); deductTF.setEditable(false); grossTF.setEditable(false); netTF.setEditable(false); calculateB = new JButton("Calculate"); cbHandler = new CalculateButtonHandler(); calculateB.addActionListener(cbHandler); clearB = new JButton("Clear"); clrHandler = new ClearButtonHandler(); clearB.addActionListener(clrHandler); exitB = new JButton("Exit"); ebHandler = new ExitButtonHandler(); exitB.addActionListener(ebHandler); JPanel panel = new JPanel(new GridLayout(9,4)); panel.add(nameLabel); panel.add(nameTF); panel.add(rateLabel); panel.add(rateTF); panel.add(hoursLabel); panel.add(hoursTF); panel.add(deductLabel); panel.add(deductTF); panel.add(grossLabel); panel.add(grossTF); panel.add(netLabel); panel.add(netTF); panel.add(calculateB); panel.add(clearB); panel.add(exitB); add(panel); pack(); setVisible(true); } private class CalculateButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e){ double rate, hours, gross, deduct, net; String name; name = nameTF.getText(); hours = Double.parseDouble(hoursTF.getText()); rate = Double.parseDouble(rateTF.getText()); gross = rate * hours; deduct = calculateWithholdingTax(gross); net = gross - deduct; nameTF.setText(""+ name); grossTF.setText(""+ gross); deductTF.setText(""+ deduct); netTF.setText(""+ net); }} private class ClearButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e){ nameTF.setText(""); rateTF.setText(""); hoursTF.setText(""); grossTF.setText(""); deductTF.setText(""); netTF.setText(""); }} private class ExitButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e){ System.exit(0); }} private double calculateWithholdingTax(double gross){ if (gross <100){ return gross *0.06; } else if (gross <300){ return gross *0.12; } else if (gross <600){ return gross *0.18; } else { return gross *0.21; }} public static void main(String[] args){ new CalcPayGui(); }}import java.io.File;import java.io.FileNotFoundException;import java.io.PrintWriter;import java.util.Scanner;public class CalcPay4{ public static void main(String[] args) throws FileNotFoundException { Scanner input = new Scanner(new File("PayIn.txt")); PrintWriter output = new PrintWriter(new File("Payout.txt")); while (input.hasNext()){ double hours = input.nextDouble(); double rate = input.nextDouble(); String name = input.next(); double grossPay = hours * rate; double deduct = calculateTax(grossPay); double netPay = grossPay - deduct; output.printf("%s,%.2f,%.2f,%.2f,%.2f,%.2f
", name, hours, rate, deduct, grossPay, netPay); System.out.printf("%s,%.2f,%.2f,%.2f,%.2f,%.2f
", name, hours, rate, deduct, grossPay, netPay); } input.close(); output.close(); } public static double calculateTax(double grossPay){ double taxRate; if (grossPay <=99.99){ taxRate =0.06; } else if (grossPay <=299.99){ taxRate =0.12; } else if (grossPay <=599.99){ taxRate =0.18; } else { taxRate =0.21; } return grossPay * taxRate; }}PayIn.txt10.0060.00 Doepublic class MyPay2{public static void main (String[] args)throws FileNotFoundException{Scanner inFile = new Scanner (new FileReader("employee.txt"));PrintWriter outFile = new PrintWriter("outpay.txt");String firstName;String lastName;double hoursWorked;double payRate;double wages;double taxAmount;double netAmount;firstName = inFile.next();lastName = inFile.next();hoursWorked = inFile.nextDouble();payRate = inFile.nextDouble();wages = hoursWorked * payRate;taxAmount = wages *.05;netAmount = wages - taxAmount;System.out.println("Paycheck for "+ firstName + lastName +". Hours worked ="+ hoursWorked +" at rate of $"+ payRate +". Gross Amount ="+ wages +" Tax Amount ="+ taxAmount +" Total Pay ="+ netAmount);outFile.println("Paycheck for "+ firstName + lastName +". Hours worked ="+ hoursWorked +" at rate of $"+ payRate +". Gross Amount ="+ wages +" Tax Amount ="+ taxAmount +" Total Pay ="+ netAmount);inFile.close();outFile.close();}employee.txtJohn Doe 40.0012.00

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!