Larry Brink

Greenhorn
+ Follow
since Aug 29, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Larry Brink

Thanks for your prompt reply Wayne, I did finnaly get the output to show. But, isn't there always a but, any way now the output shows, the calculation is correct for gross pay, and for net pay, the problem now is, or I am thinking something with the array. If, for example a persons income is 0 - 99.99, then the withholding would be 10. For 100 - 299.99, the withholding should be 15, and so on. Now that is where the problem comes in. For some reason the withholding is stuck on, or only shows 10, instead of coresponding to the income array.
I did set the withHoldingAmount = withHolding [x];
Now that should make the withHolding correspond to the income, correct.
once again here is my code.

Again, I would appreciate either a point in the right direction, or if need be, a swift kick, hopefully the first.
Thanks for any and all pointers.
Larry
20 years ago
Greetings, I am new to java, I have been working on an applet, which so far compiles and mostly works okay. The problem is the screen output after the calculation in the ActionPerformed Method, there is none showing. I am hoping some one will help point me in the right direction so I can figure out why. At this point, I have been working on this applet long enough that I think I am brain Dead. My code is below.
import javax.swing.*; //Must import both of these
import java.awt.*; //for every java applet
import java.awt.event.*; // for the event class,(ActionListener)
import java.applet.*; //Must import for extends Applet
import java.text.*;
/**
* Program for the CalcPay class.
*
* @author Larry Brink
* @version 11/18/2003
*/
public class CalcPay extends JApplet implements ActionListener
{
//need in every applet, the container contains eveything in the applet
Container con = getContentPane();
//creating label for enter hours
JLabel enterHours = new JLabel("Enter Hours Worked");
//creating label for enter rate
JLabel enterRate = new JLabel("Enter Hourly Rate");
Label seeStart = new Label("");
//creating label for gross pay
JLabel gross = new JLabel("");
//creating label for net pay
JLabel net = new JLabel("");
//creating label for withholding
JLabel holding = new JLabel("");
//creating Button for calculate pay
JButton calculatePay = new JButton("Calculate Pay");
//creating text field for entering hours worked
JTextField hoursWorked = new JTextField(2);
//creating text field for entering hourly rate
JTextField hourlyRate = new JTextField(5);
//Font myNewFont changes the Font, the "+" needs to be used to use both Italic and Bold
Font myFont = new Font ("Arial", Font.BOLD +Font.ITALIC, 14);

/**
* Description of the Method
*/
public void init() // initialize the Method
{
//setting the Container Layout, different way then used above
con.setLayout (new FlowLayout());
//setting the font style for the JLabels
enterHours.setFont (myFont);
enterRate.setFont (myFont);
calculatePay.setFont (myFont);
con.add (enterHours); //adds the JLabel enterHours
con.add (hoursWorked); //adds the JTextField hoursWorked
con.add (enterRate); //adds the JLabel enterRate
con.add (hourlyRate); //adds the JTextField hourlyRate
calculatePay.setForeground(Color.red);
calculatePay.setBackground(Color.blue);
con.add (calculatePay);//adds the JButton calculatePay
con.add(gross); //adds the JLabel gross pay
con.add(net); //adds the JLabel net pay
con.add(holding); //adds the JLabel withholding
calculatePay.addActionListener(this);
hoursWorked.requestFocus();
}

/**
* Description of the method
* param thisCalc Description of the parameter
*/

public void actionPerformed(ActionEvent thisCalc)
{
int[] income = {0, 100, 300, 600};
int[] withHolding = {10, 15, 21, 28};
int hours = Integer.parseInt(hoursWorked.getText ());
double rate = Double.parseDouble(hourlyRate.getText ());
int withHoldingAmount = 0;
double netPay = 0;
double grossPay = 0;
int x = income.length;

for (x = income.length; x >= 0; --x)
{
if (grossPay >= income [x])
{
withHoldingAmount = withHolding[x];
grossPay = hours * rate;
netPay = grossPay - withHoldingAmount;
x = 0;

}
}
gross.setText("Your gross pay is $ " + grossPay);
net.setText("Your net pay is $ " + netPay);
holding.setText("Your withholding is $ " + withHoldingAmount);
}
}
Please take it easy on me, I am new to this. Thanks in advanced for any and all help.
Larry
20 years ago
Thanks to all that posted. I do finaly have it working, my settings were all correct, j2sdk1.4.1 is installed, I just seem to have a problem reading files from a certain removable disk, why I don't know that yet, but I will soon. At least I can now get down to learning this language. Again thanks to every one. Just hope it wasn't a dump question in the first place.
Larry
21 years ago
Good day to all. I am just starting out with Java, I am taking class at a local college, actually for Web Analyst/Programmer. But any way, I did have the j2sdk1.4.1 installed on my computer, our instructor advised us that we will be using a program called BlueJ. After installing BlueJ I can not compile any thing at all from the command prompt, I get the message:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
D:\Documents and Settings\OURS>cd
D:\Documents and Settings\OURS
D:\Documents and Settings\OURS>A:
A:\>javac Tree1.java
'javac' is not recognized as an internal or external command,
operable program or batch file.
A:\>
Ok, so now what is wrong. What I did was completely uninstall the j2sdk1.4.1. and BlueJ. Reinstalled j2sdk1.4.1 and I get the same exact message. Below is what is set in the Enviroment variables on my computer.
(This is what is set in the Enviroment Variables
Enviroment Variables
VariableValue
CLASSPATH D:\j2sdk1.4.1\bin\;.;
Variable nameVariable Value
PathD:\j2sdk1.4.1\bin\;.;
Now of course there is more to the Path Variable then what is shown above, but what you see abouve for the Path is added to the end of the Path. Any suggestions as to what I might try next. Please.
Thank You in advanced for any and all help from this message board. I have a feeling I will be visiting here quite often.
Larry
21 years ago