I have changed most of the PUBLIC to PRIVATE. How do i code Private?
import javax.swing.*;
import java.awt.event.*;
import java.awt.*; //Colors
import java.text.*; //For formatting
import java.util.*;
public class Proj4MaSApplet extends JApplet implements ActionListener
{
//Create the components
JPanel outputPanel = new JPanel();
JPanel inputPanel = new JPanel();
JTextField nameTextField = new JTextField(15);
JTextField bpriceTextField = new JTextField();
JTextField quanTextField = new JTextField();
JTextField extendedTextField = new JTextField();
JTextArea payrollTextArea =
new JTextArea(10, 20);
JButton calculateButton = new JButton("Calculate Pay");
JLabel payLabel = new JLabel();
JLabel bookssoldLabel = new JLabel();
JLabel avgLabel = new JLabel();
JLabel dateLabel = new JLabel();
JLabel nameLabel = new JLabel();
JPanel mainPanel = new JPanel();
//Declare class variables
int numberProcessedInteger = 0; //int is integer data
float totalPayFloat = 0.0f; //float is single precision floating point number
Calendar currentCalendar = Calendar.getInstance();
int dayInteger = currentCalendar.get(Calendar.DATE);
int monthInteger = currentCalendar.get(Calendar.MONTH);
int yearInteger = currentCalendar.get(Calendar.YEAR);
private void init()
{
//Create Interface
designInputPanel();
designOutputPanel();
mainPanel.add(inputPanel);
mainPanel.add(outputPanel);
mainPanel.add(payrollTextArea);
setContentPane(mainPanel);
addListeners();
}
private void actionPerformed(ActionEvent event)
{
//Retrieve data and calculate
//Declare local variables
String formattedString;
try
{
//Obtain data from text boxes
//Conver Strings to float values
float rateFloat = Float.parseFloat(quanTextField.getText());
try
{
float hoursFloat = Float.parseFloat(bpriceTextField.getText());
//Calculate pay and totals
float payFloat= hoursFloat * rateFloat;
totalPayFloat += payFloat; //Add pay to total pay
float percentFloat = payFloat * 15/100;
float discountFloat=totalPayFloat - percentFloat;
float avgFloat = discountFloat / rateFloat;
//Set local formatting
NumberFormat currencyNumberFormat = NumberFormat.getCurrencyInstance();
NumberFormat decimalNumberFormat = NumberFormat.getInstance();
decimalNumberFormat.setMinimumFractionDigits(2);
decimalNumberFormat.setMaximumFractionDigits(2);
//Format and display results
formattedString = currencyNumberFormat.format(discountFloat);
payLabel.setText(formattedString);
formattedString =decimalNumberFormat.format(rateFloat);
bookssoldLabel.setText(formattedString);
formattedString = currencyNumberFormat.format(avgFloat);
avgLabel.setText(formattedString);
dateLabel.setText("" + currentCalendar.get(Calendar.DATE) + currentCalendar.get(Calendar.MINUTE));
//Place the currency format for each Float
payrollTextArea.append("Title:" + "" + nameTextField.getText()
+ "\n"+ "Price:" +
currencyNumberFormat.format(Double.parseDouble(bpriceTextField.getText()))
+ "\n" + "Quantity: " + " " + quanTextField.getText()
+ "\n" + "Extended Price: " +currencyNumberFormat.format(payFloat)
+"\n" + "Discount Amount:" + currencyNumberFormat.format(percentFloat)
+"\n" + "Dicounted Price: " + currencyNumberFormat.format(discountFloat));
//Clear text fields
nameTextField.setText("");
bpriceTextField.setText("");
quanTextField.setText("");
nameTextField.requestFocus();
}
catch (NumberFormatException err)
{
JOptionPane.showMessageDialog(null, "Hours are invalid.");
}
}
catch (NumberFormatException err)
{
JOptionPane.showMessageDialog(null, "rate is invalid");
}
}
private void designOutputPanel()
{
//Lay the output panel
outputPanel.setLayout(new GridLayout(0,2));
outputPanel.add(new Label("Total Books Sold:"));
outputPanel.add(bookssoldLabel);
outputPanel.add(new Label("Total Of Sales:"));
outputPanel.add(payLabel);
outputPanel.add(new JLabel("Average Price Of Book:"));
outputPanel.add(avgLabel);
outputPanel.add(new Label("Stanley Ma"));
outputPanel.add(nameLabel);
outputPanel.add(new Label("Today is:" + monthInteger + "/" +
dayInteger+ "/"
+ yearInteger));
outputPanel.add(dateLabel);
outputPanel.add(calculateButton);
}
private void designInputPanel()
{
//Lay out he input panel
inputPanel.setLayout(new GridLayout(0,1));
inputPanel.add(new JLabel("Book Title:"));
inputPanel.add(nameTextField);
inputPanel.add(new JLabel("Price:"));
inputPanel.add(bpriceTextField);
inputPanel.add(new JLabel("Quantity:"));
inputPanel.add(quanTextField);
}
private void addListeners()
{
nameTextField.requestFocus();
calculateButton.addActionListener(this);
}
}

