0

I used this statement so that it would convert the string input in textfield to a double,

Where is the converted value saved in a variable? That code does NOT assign any value to a variable. The converted value is discarded.
That statement calls two methods: equals() and parseDouble() and does NOT save the values returned by either.

0
private class CalcListener implements ActionListener{
		
		public void actionPerformed(ActionEvent e){
			String centInput = centText.getText() , inchInput = inchText.getText(), meterInput = meterText.getText(), 
			yardInput = yardsText.getText();
			double cent=0, inch=0, meter=0, yard=0;
			
			DecimalFormat beagle = new DecimalFormat("0.00");
			
			if(!yardsText.getText().equals("0.00"))
			{
				yardInput.equals(Double.parseDouble(yardsText.getText()));
				yard = Double.parseDouble(yardInput);
				inch = Double.parseDouble(yardInput) * 36.00;
				cent = Double.parseDouble(yardInput) * 91.44;
				meter = Double.parseDouble(yardInput) * 0.9144;
				
				yardsText.setText(String.valueOf(beagle.format(yard)));
				inchText.setText(String.valueOf(beagle.format(inch)));
				centText.setText(String.valueOf(beagle.format(cent)));
				meterText.setText(String.valueOf(beagle.format(meter)));
				
			}
0

This statement does NOTHING useful:
yardInput.equals(Double.parseDouble(yardsText.getText()));

It can be removed and not change any of the results.

0

Line 4 and 5 declare the strings and assign the textfields to the "input" variables.
Line 10 checks to see if there is an input the textfield other than the default "0.00"
Line 12 converts the string data in yardsText into a double, which allows
Lines 13-16 to use yardInput for conversions.

0

You are correct(not that I doubted your knowledge). I was just trying to explain what I thought was going on. Thanks for pointing out that I had useless code in there. Now I am trying to figure out why I put it in there ;/.

Edited by javaNooblet: n/a

0

Many of the methods you call RETURN values that should be stored/saved in a variable. If you do NOT save them then the work done by the method is LOST!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.