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

//Folder/Project Name: ifGUI //Programmer Name: Example //Date: 9/29/2008 //Clas

ID: 3641509 • Letter: #

Question

//Folder/Project Name: ifGUI
//Programmer Name: Example
//Date: 9/29/2008
//Class Name: IfGUIApplication
/*Project Description: This class demonstrates compound if statements
*/
import javax.swing.*;
import java.awt.event.*;
import java.text.*;
import java.awt.*;

public class IfGUIApplication extends JFrame
implements ActionListener
{
//declare your instance objects here
JPanel mainPanel = new JPanel();
JLabel nameLabel = new JLabel("Example");
JButton displayButton = new JButton("Display Answer");
JTextArea outputTextArea = new JTextArea(5, 20);
Font boldFont = new Font("Times New Roman", Font.BOLD, 20);

//Declare instance variables and constants
int countEmplInteger;
double totalGrossPayDouble;


public static void main(String[] args)
{
// This is the first method called in a application
//We will create an object of ourselves to call the
//constructor and then set the default close operation for the frame

IfGUIApplication basicGUI = new IfGUIApplication();
basicGUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}//end of main

public IfGUIApplication()
{
//This is the constructor for this class. It will be called from main
//call the superclass' constructor and send a title
super("A Shell GUI Application");

//sets the background color of the panel
mainPanel.setBackground(Color.YELLOW);
nameLabel.setFont(boldFont);

//sets the text color of the name label
nameLabel.setForeground(Color.RED);
mainPanel.add(nameLabel);
mainPanel.add(displayButton);
mainPanel.add(outputTextArea);

//add the JPanel to the JFrame
this.add(mainPanel);

addListeners();

//set the layout manager (later in the course)

//add GUI components to the appropriate container

//set the properties of the JFrame for display
this.setSize(250, 300);
this.setVisible(true);
}//end of constructor

//add the listener to the appropriate components
public void addListeners()
{
displayButton.addActionListener(this);

}

//check the if statement and display the answer
public void actionPerformed(ActionEvent evt)
{
//Retrieve input from the user
//convert the text to primitive data types

int x = 0, y = 5, z = 10;


//see page 214 of your textbook - there is a statement
//that is not correct as I read it! The expression is still evaluated
//from left to right - the && gets bound with the y and z expressions first!
if(x++ == 0 || ++y > 6 && z == 10)
outputTextArea.setText(" TRUE: x = " + x + " y = " + y + " z = " + z);
else
outputTextArea.setText(" FALSE: x = " + x + " y = " + y + " z = " + z);
/*
if(x++ < 0 || ++y > 6 && z == 10)
outputTextArea.setText(" TRUE: x = " + x + " y = " + y + " z = " + z);
else
outputTextArea.setText(" FALSE: x = " + x + " y = " + y + " z = " + z);
*/

}

}//end of class

----------------------------------------------------------------------
*Note* "For the codes above, we are to use them as an example as a reference, but I am not sure if it is the right codes for this homework assignment. Please help!"

_Programming in Java
Homework/Lab Assignment 4
For this assignment, you will be completing your next project. Your project must be created in Eclipse editor and it should reflect the documentation that you turned in.
Problem Description
SAC, Inc pays its employees monthly based on a combination of base pay plus commission. The base pay is determined by the years of service in the company, per the table below:
Years of Service Base Pay
<1 $1,000
1-3 (less than 3) $1,200
3-5 (less than 5) $1,500
5+ $1,700
The commission is based on the gross sales made by the employee that month, per the table below:
Sales Commission Rate (% of Sales)
$0 - $20,000 1%
$20,001 - $30,000 2%
$30,000+ 3%
The company wants you to create a GUI application that will accept the employee’s name, the years of service, and gross sales amount and display the Base Pay, Commission Amount and %, and the Total Gross Pay for the employee, which is Base Pay plus Commission Amount. In addition, you will need to accumulate these values in order to display grand totals.
Input
• Employee name
• Years of service (whole numbers)
• Gross sales (decimal number)
• Three buttons: one for calculating and displaying the gross sales for the employee, one to clear out all input text fields (not the text area), and one for displaying the summary totals.
Processing
Use a GUI JFrame application that displays all of the components to the user in a professional, easily read layout. Use the size of individual components and the overall size of the JFrame to help align items cleanly. At the top of the JFrame, include a label containing the company name and somewhere in the panel another label with your name as the programmer displayed. You may use font size to help with the layout.
When the calculate button is pressed, complete the following:
• Validate the name to make sure that something has been entered. If the user has not entered anything into the name field, send a message using the JOptionPane class and reposition the insertion point in the name text field. Also, verify that numeric fields actually have valid numbers entered using try and catch for exceptions. (Do NOT do any calculations if any data is missing or numeric fields have errors).
• Calculate the gross pay, which is the base pay plus the commission amount.
• Accumulate totals of sales, base pay, commission and total salary.
• Display name, sales, base pay, commission amount and percent, and total as shown under Output. Display this in the text area.
When the clear button is pressed, complete the following:
• clear out all input text field data and reposition the insertion point (cursor) in the first text field.
When the summary button is pressed, display the following in a JOptionPane message box:
• display the accumulated Sales, Base Pay, Commission, and Total in a JOptionPane. Make sure that the message in the JOptionPane is formatted so that the information is easily read.
Output
• Display the output from the calculation button processing in a columnar format in a text area as follows. Notice that both the commission amount and percentage are required in the display. Use the format method discussed in class to line up the numbers (and column headings) so that they are right-aligned.
Name Sales Base Pay Commission Total
Joe Bloe $25,000.00 $1,000.00 $500.00 (2%) $1,500.00
Sally Smith $15,000.00 $1,500.00 $150.00 (1%) $1,650.00
Additional Requirements
• Use try/catch blocks to catch bad input for numeric fields
• Make sure that your text area has scroll bars so that data will not be inaccessible as additional lines get displayed
• Use constants wherever appropriate. At a minimum, consider using them for the commission percentages and the base pay values.
• Display the company name and your name as programmer in labels on the GUI.
• Reposition the insertion point into the first text field when the clear button is pressed (and only when this button is pressed).
• Make the GUI look professional and easy to read.
• Use correct naming conventions in your program. Indent the program source code correctly, leaving blank lines where appropriate. Include the recommended remarks in the Java source code., and include a both a Java Class Diagram and pseudocode of each method as documentation. Also make sure that you fill out the top portion of an Evaluation Sheet (named correctly) and include that as part of your documentation.
---------------------------
*Note* "These are the documentations that I have to do as well. These documents will relate to the codes."

Pseudocode Form
Lab Assign Number: __4__ Class Name : ___CISP 21_____________________
import the package ______________________ for the ______________________________
import the package ______________________ for the ______________________________
In the class:


main method:



-------------------------------------------------------------
*Note* "For this documentation, I have to type what the results will be displayed on the console. I can either write or put text boxes if necessary."

Interface Plan - Design (Picture)
Project : _____EMPLOYEE_____________
Class : _________CISP 21__________

--------------------------------------------------
*Note* "For this class Diagram, It will have to relate to the codes used in Eclipse.
I will be really appreciated if anyone can help me. Please and thank you."

Class Diagram
Project Name and Number: ___Employee___________________________________________________

[Class Name] (include a separate page for each class)
Variables and Objects (include all components used)
Instance Variables and Objects
Variable / Object Name | Type of Variable / Object










Local Variables and Objects
Variable / Object Name | Type of Variable / Object





Constants
Constant | Type of Constant






Class Variables
Variable / Object Name | Type of Variable / Object




Methods
Method name | Return type of method


















































Explanation / Answer

I did the most tahat i could im very tired if you need more help pleas ask to my email
------------------------------------------------------------------------------------------------
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SpringLayout.Constraints;
import javax.swing.SwingConstants;

import world.Sac;


public class Interface extends JFrame implements ActionListener
{
//-------------------------------
//Attributes
//-------------------------------
public final static String CLEAR = "Clear";

public final static String CALCULATE = "Calculate";

public final static String TOTAL = "Total";

//-------------------------------
//Attributes
//-------------------------------

/**
* Represents a new world
*/
private Sac main;

private JButton butCalculate;

private JButton butTotal;

private JButton butClear;

//-------------------------------
//Attributes of the GUI
//-------------------------------

public Interface()
{
setLayout( new BorderLayout( ) );
setSize( 300, 500 );
setTitle( "CupiTrenes" );
setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
setLocationRelativeTo( null );

JLabel labName = new JLabel("SAC inc.");
labName.setHorizontalAlignment(SwingConstants.CENTER);
add(labName, BorderLayout.NORTH);

JPanel center = new JPanel();
center.setLayout(new BorderLayout());

JPanel input = new JPanel();
input.setLayout(new GridLayout(3,2));

JLabel labName1 = new JLabel("Name: ");
JTextField txtName1 = new JTextField("");
JLabel labsales1 = new JLabel("Sales:");
JTextField txtSales1 = new JTextField("");
JLabel labYears1 = new JLabel("Years of service:");
JTextField txtYears1 = new JTextField("");

input.add(labName1);
input.add(txtName1);
input.add(labYears1);
input.add(txtYears1);
input.add(labsales1);
input.add(txtSales1);

center.add(input , BorderLayout.NORTH);

JPanel butons = new JPanel();
butons.setLayout(new GridLayout(1,3));

butCalculate = new JButton("Calculate");
butCalculate.addActionListener(this);
butCalculate.setActionCommand(CALCULATE);

butTotal = new JButton("Total");
butTotal.addActionListener(this);
butTotal.setActionCommand(TOTAL);

butClear = new JButton("Clear");
butClear.addActionListener(this);
butClear.setActionCommand(CLEAR);

butons.add(butCalculate);
butons.add(butTotal);
butons.add(butClear);

center.add(butons, BorderLayout.CENTER);

JPanel output = new JPanel();
output.setLayout(new GridLayout(3,2));

JLabel labName2 = new JLabel("Name: ");
JTextField txtName2 = new JTextField("");
JLabel labsales2 = new JLabel("Sales:");
JTextField txtSales2 = new JTextField("");
JLabel labYears2 = new JLabel("Years of service:");
JTextField txtYears2 = new JTextField("");

output.add(labName2);
output.add(txtName2);
output.add(labYears2);
output.add(txtYears2);
output.add(labsales2);
output.add(txtSales2);

center.add(output, BorderLayout.SOUTH);

add(center);

}
//-------------------------------
//Main
//-------------------------------
public static void main (String [] args)
{
try
{
Interface random = new Interface();
random.setVisible(true);
}
catch (Exception e)
{
System.out.print(e.getMessage());
}
}
@Override
public void actionPerformed(ActionEvent e)
{
String comand = e.getActionCommand();


}
}

-----------------------------------------------------------------------------------------------

package world;


/**
* @author
* Represents the main class
*/
public class Sac
{
//-------------------
//Constants
//-------------------


/**
* Represents the base pay if the years of service <1
*/
public final static double FIRSTBASE = 1000;

/**
* Represents the base pay if the years of service 1 -3
*/
public final static double SECONDBASE = 1200;

/**
* Represents the base pay if the years of service 3 - 5
*/
public final static double THIRDBASE = 1500;

/**
* Represents the base pay if the years of service >5
*/
public final static double FOURTHBASE = 1700;


/**
* Represents the comision if the grosssales are 0 - 20000
*/
public final static double FIRSTCOMISSION = 0.01;

/**
* Represents the comision if the grosssales are 20001 - 30000
*/
public final static double SECONDCOMISSION = 0.02;

/**
* Represents the comision if the grosssales are > 30000
*/
public final static double THIRDCOMISSION = 0.03;
//-------------------
//Attributes
//-------------------


/**
* Represents the name of the employee
*/
private String name;

/**
* Represents the years of service of the employee
*/
private int yearsOfService;

/**
* Represents te gross sales of the employee
*/
private double grossSales;

//-------------------
//Constructors
//-------------------

/**
* Creates a new world
*/
public Sac()
{
name = "";
yearsOfService = 0;
grossSales = 0;
}

//-------------------
//Methods
//-------------------

/**
* Sets a new employee
*/
public void setNullValues()
{
name = "";
yearsOfService = 0;
grossSales = 0;
}


/**
* Creates a new employee with the parameters
* @param pName the name of the new employee
* @param pYears the years of service of the new employee
* @param pGross the gross sales of the new employee
*/
public void setNewEmployee(String pName, int pYears, double pGross)
{
name = pName;
yearsOfService = pYears;
grossSales = pGross;
}

/**
* @return the base salary of the employee
* the salary depends of the years of service
*/
public double getBaseSalary()
{
if(yearsOfService == 0)
{
return FIRSTBASE;
}
else if(yearsOfService > 0 && yearsOfService < 3)
{
return SECONDBASE;
}
else if(yearsOfService >= 3 && yearsOfService < 5)
{
return THIRDBASE;
}
else if(yearsOfService >=5)
{
return FOURTHBASE;
}

else
{
return -1;
}
}

/**
* @return The comission of the employee base on the gross sales
*/
public double getComission()
{
if(grossSales >= 0 && grossSales<= 20000)
{
return grossSales * FIRSTCOMISSION;
}
else if(grossSales >= 20001 && grossSales<= 30000)
{
return grossSales * SECONDCOMISSION;
}
else if(grossSales >= 30001)
{
return grossSales * THIRDCOMISSION;
}
else
{
return -1;
}
}

/**
* @return The total salary of the employee. Base + comissions
*/
public double getTotales()
{
return getComission() + getBaseSalary();
}
}
---------------------------------------------------------------------------------------

I think that you cand progress with this, there is the world that you need to do some changes in the grossSalary and the interface you neer to complete but there is a help. Dont doubt on ask for more help i will be glad on helping you