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);
			}
		}

Recommended Answers

All 2 Replies

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.