0

cant figure out why summaryCounter wont increment??

if 	(source == calculateButton)
		{
			int summaryCounter = 1;

		    double payment = Double.parseDouble(paymentTextField.getText());
            double rate = Double.parseDouble(rateTextField.getText());
            int years = (Integer)yearsComboBox.getSelectedItem();
            DecimalFormat currency = new DecimalFormat("  ##,##0.00");
            double futureValue;
            String s;
            int i;
            futureValueListModel.clear();

            System.out.printf("\n  Investment Summary Option %d \n  Monthly Payment%,10.2f\n  Interest Rate    %8.1f\n  Years Invested   %8d\n\n", summaryCounter, payment, rate, years);
            summaryCounter++;
            for ( i = 1; i <= years; i++)
            {
				summaryCounter++;
                futureValue = FinancialCalculations.calculateFutureValue(
                    payment, rate, i);
                s = "  Year " + i + ": " + currency.format(futureValue);
                futureValueListModel.addElement(s);
                System.out.println(s);
			}
		}
3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by verruckt24
0

So where you do use it AFTER you have incremented it?

So far, you only print it once, when it's value has been initialised to 1.

0

Where are you using the counter to check whether it has been incremented or not. Post the entire code.

PS: He beat me to it.

Edited by verruckt24: n/a

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.