Chat LIVE With Programming Experts! There Are 23 Online Right Now...

Welcome to Dream.In.Code
Become a Java Expert!

Join 244,072 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,321 people online right now. Registration is fast and FREE... Join Now!




Compiles but does nt run.

 
Reply to this topicStart new topic

Compiles but does nt run.

jgear
7 Sep, 2008 - 07:23 AM
Post #1

New D.I.C Head
*

Joined: 17 Aug, 2008
Posts: 47



Thanked: 1 times
My Contributions
java
import java.io.*;
import java.util.Date;
import java.text.DecimalFormat;





public class MortgageCalculator{

public static void main(String[] args){
//Declares and builds the variable of the loan amount
int loanAmount = 200000;
double loanBalance = 0;
double interestPaid = 0;
int loanTerm[] = {84, 180, 360};
double interest[] = {.0535, .0550, .0575};
double monthlyPayment = 0;
DecimalFormat money =new DecimalFormat("0.00");

//Starts array loop
for (int i = 0; i < 3; i++) {
//Declares formula
monthlyPayment = (loanAmount*(interest[i]/12)) / (1 - 1 /Math.pow((1 + interest[i]/12), loanTerm[i]));

//Displays loop with first mortgage and interest paid
if (i == 1)
monthlyPayment = (loanAmount*(interest[0]/12)) / (1 - 1 /Math.pow((1 + interest[0]/12), loanTerm[0]));
loanBalance = loanBalance - monthlyPayment;
interestPaid = monthlyPayment * interest[0];

while (loanBalance > 0){

//Displays Mortgage Calculator with the first terms
System.out.println("Mortgage Calculator");
System.out.println("The loan amount is $200,000");
System.out.println("The term of the loan is " + loanTerm[0]);
System.out.println("The monthly payment is $" + money.format(monthlyPayment));
System.out.println("The loan balance is: $" + money.format(loanBalance));
System.out.println("The interest paid for the loan is $" + money.format(interestPaid));
System.out.println();

loanBalance = loanAmount - monthlyPayment;
interestPaid = monthlyPayment * interest[0];}

//Displays loop with second mortgage and interest paid
if (i == 2)
while (loanBalance > 0){
//Declares formulas
monthlyPayment = (loanAmount*(interest[1]/12)) / (1 - 1 /Math.pow((1 + interest[1]/12), loanTerm[1]));
loanBalance = loanAmount - monthlyPayment;
interestPaid = monthlyPayment * interest[1];

//Displays Mortgage Calculator with the first terms until balance equals zero
System.out.println("Mortgage Calculator");
System.out.println("The loan amount is $200,000");
System.out.println("The term of the loan is " + loanTerm[1]);
System.out.println("The monthly payment is $" + money.format(monthlyPayment));
System.out.println("The loan balance is: $" + money.format(loanBalance));
System.out.println("The interest paid for the loan is $" + money.format(interestPaid));
System.out.println();}

//Displays loop with third mortgage and interest paid
if (i == 3)
while (loanBalance > 0){
//Declares formulas
monthlyPayment = (loanAmount*(interest[2]/12)) / (1 - 1 /Math.pow((1 + interest[2]/12), loanTerm[2]));
loanBalance = loanAmount - monthlyPayment;
interestPaid = monthlyPayment * interest[2];

//Displays Mortgage Calculator with the first terms until balance equals zero
System.out.println("Mortgage Calculator");
System.out.println("The loan amount is $200,000");
System.out.println("The term of the loan is " + loanTerm[2]);
System.out.println("The monthly payment is $" + money.format(monthlyPayment));
System.out.println("The loan balance is: $" + money.format(loanBalance));
System.out.println("The interest paid for the loan is $" + money.format(interestPaid));
System.out.println();}
}
}
}


For some reason this calculator does not run. It compiles successfully but when I run it all I get as an output is "press any key to continue"
I know I am missing something stupid here. Any help would be great.

User is offlineProfile CardPM
+Quote Post


jgear
RE: Compiles But Does Nt Run.
7 Sep, 2008 - 09:06 AM
Post #2

New D.I.C Head
*

Joined: 17 Aug, 2008
Posts: 47



Thanked: 1 times
My Contributions
QUOTE(jgear @ 7 Sep, 2008 - 08:23 AM) *

java
import java.io.*;
import java.util.Date;
import java.text.DecimalFormat;





public class MortgageCalculator{

public static void main(String[] args){
//Declares and builds the variable of the loan amount
int loanAmount = 200000;
double loanBalance = 0;
double interestPaid = 0;
int loanTerm[] = {84, 180, 360};
double interest[] = {.0535, .0550, .0575};
double monthlyPayment = 0;
DecimalFormat money =new DecimalFormat("0.00");

//Starts array loop
for (int i = 0; i < 3; i++) {
//Declares formula
monthlyPayment = (loanAmount*(interest[i]/12)) / (1 - 1 /Math.pow((1 + interest[i]/12), loanTerm[i]));

//Displays loop with first mortgage and interest paid
if (i == 1)
monthlyPayment = (loanAmount*(interest[0]/12)) / (1 - 1 /Math.pow((1 + interest[0]/12), loanTerm[0]));
loanBalance = loanBalance - monthlyPayment;
interestPaid = monthlyPayment * interest[0];

while (loanBalance > 0){

//Displays Mortgage Calculator with the first terms
System.out.println("Mortgage Calculator");
System.out.println("The loan amount is $200,000");
System.out.println("The term of the loan is " + loanTerm[0]);
System.out.println("The monthly payment is $" + money.format(monthlyPayment));
System.out.println("The loan balance is: $" + money.format(loanBalance));
System.out.println("The interest paid for the loan is $" + money.format(interestPaid));
System.out.println();

loanBalance = loanAmount - monthlyPayment;
interestPaid = monthlyPayment * interest[0];}

//Displays loop with second mortgage and interest paid
if (i == 2)
while (loanBalance > 0){
//Declares formulas
monthlyPayment = (loanAmount*(interest[1]/12)) / (1 - 1 /Math.pow((1 + interest[1]/12), loanTerm[1]));
loanBalance = loanAmount - monthlyPayment;
interestPaid = monthlyPayment * interest[1];

//Displays Mortgage Calculator with the first terms until balance equals zero
System.out.println("Mortgage Calculator");
System.out.println("The loan amount is $200,000");
System.out.println("The term of the loan is " + loanTerm[1]);
System.out.println("The monthly payment is $" + money.format(monthlyPayment));
System.out.println("The loan balance is: $" + money.format(loanBalance));
System.out.println("The interest paid for the loan is $" + money.format(interestPaid));
System.out.println();}

//Displays loop with third mortgage and interest paid
if (i == 3)
while (loanBalance > 0){
//Declares formulas
monthlyPayment = (loanAmount*(interest[2]/12)) / (1 - 1 /Math.pow((1 + interest[2]/12), loanTerm[2]));
loanBalance = loanAmount - monthlyPayment;
interestPaid = monthlyPayment * interest[2];

//Displays Mortgage Calculator with the first terms until balance equals zero
System.out.println("Mortgage Calculator");
System.out.println("The loan amount is $200,000");
System.out.println("The term of the loan is " + loanTerm[2]);
System.out.println("The monthly payment is $" + money.format(monthlyPayment));
System.out.println("The loan balance is: $" + money.format(loanBalance));
System.out.println("The interest paid for the loan is $" + money.format(interestPaid));
System.out.println();}
}
}
}


For some reason this calculator does not run. It compiles successfully but when I run it all I get as an output is "press any key to continue"
I know I am missing something stupid here. Any help would be great.


Ok. I think the program is running I have just forgotten to pause the display. However, I am now having a hard time getting the pause to work.
java
import java.io.*;
import java.util.Date;
import java.text.DecimalFormat;





public class mortgage4{

public static void main(String[] args){
//Declares and builds the variable of the loan amount
int loanAmount = 200000;
double loanBalance = 0;
double interestPaid = 0;
int loanTerm[] = {84, 180, 360};
double interest[] = {.0535, .0550, .0575};
double monthlyPayment = 0;
DecimalFormat money =new DecimalFormat("0.00");

//Starts array loop
for (int i = 0; i < 3; i++) {
//Declares formula
monthlyPayment = (loanAmount*(interest[i]/12)) / (1 - 1 /Math.pow((1 + interest[i]/12), loanTerm[i]));

//Displays loop with first mortgage and interest paid
if (i == 1)
monthlyPayment = (loanAmount*(interest[0]/12)) / (1 - 1 /Math.pow((1 + interest[0]/12), loanTerm[0]));
loanBalance = loanBalance - monthlyPayment;
interestPaid = monthlyPayment * interest[0];

while (loanBalance > 0){

//Displays Mortgage Calculator with the first terms
System.out.println("Mortgage Calculator");
System.out.println("The loan amount is $200,000");
System.out.println("The term of the loan is " + loanTerm[0]);
System.out.println("The monthly payment is $" + money.format(monthlyPayment));
System.out.println("The loan balance is: $" + money.format(loanBalance));
System.out.println("The interest paid for the loan is $" + money.format(interestPaid));
System.out.println();

loanBalance = loanAmount - monthlyPayment;
interestPaid = monthlyPayment * interest[0];}

//Displays loop with second mortgage and interest paid
if (i == 2)
while (loanBalance > 0){
//Declares formulas
monthlyPayment = (loanAmount*(interest[1]/12)) / (1 - 1 /Math.pow((1 + interest[1]/12), loanTerm[1]));
loanBalance = loanAmount - monthlyPayment;
interestPaid = monthlyPayment * interest[1];

//Displays Mortgage Calculator with the first terms until balance equals zero
System.out.println("Mortgage Calculator");
System.out.println("The loan amount is $200,000");
System.out.println("The term of the loan is " + loanTerm[1]);
System.out.println("The monthly payment is $" + money.format(monthlyPayment));
System.out.println("The loan balance is: $" + money.format(loanBalance));
System.out.println("The interest paid for the loan is $" + money.format(interestPaid));
System.out.println();}

//Displays loop with third mortgage and interest paid
if (i == 3)
while (loanBalance > 0){
//Declares formulas
monthlyPayment = (loanAmount*(interest[2]/12)) / (1 - 1 /Math.pow((1 + interest[2]/12), loanTerm[2]));
loanBalance = loanAmount - monthlyPayment;
interestPaid = monthlyPayment * interest[2];

//Displays Mortgage Calculator with the first terms until balance equals zero
System.out.println("Mortgage Calculator");
System.out.println("The loan amount is $200,000");
System.out.println("The term of the loan is " + loanTerm[2]);
System.out.println("The monthly payment is $" + money.format(monthlyPayment));
System.out.println("The loan balance is: $" + money.format(loanBalance));
System.out.println("The interest paid for the loan is $" + money.format(interestPaid));
System.out.println();}


}
}
}
//Pauses screen
if (lineCount ==15) {
lineCount--;

try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}

User is offlineProfile CardPM
+Quote Post

BigAnt
RE: Compiles But Does Nt Run.
7 Sep, 2008 - 11:08 AM
Post #3

May Your Swords Stay Sharp
Group Icon

Joined: 16 Aug, 2008
Posts: 2,384



Thanked: 95 times
Dream Kudos: 75
My Contributions
The way the program is written nothing will be printed out. The if statements do not have the { } brackets surrounding them so they will terminate as soon as they hit the next ';', anything after that will be eexcuted each time through the loop.

The loanBalance is also never initially set to anything besides 0, which means the while loops will never execute, the loan balance needs to be reset each time through the loop at each of the if statements.

The statement
loanBalance = loanAmount - monthlyPayment;
in each of the while loops should be
loanBalance = loanBalance - monthlyPayment;
in the first statement the loanBalance will be reset to 200000 resulting
in an infinite loop.

Also the if statements should start at if (i == 0) and go to if(i == 2)
in the for loop you have if(i == 3) will never be executed cause i will never be greater than 2
User is offlineProfile CardPM
+Quote Post

jgear
RE: Compiles But Does Nt Run.
7 Sep, 2008 - 12:33 PM
Post #4

New D.I.C Head
*

Joined: 17 Aug, 2008
Posts: 47



Thanked: 1 times
My Contributions
QUOTE(BigAnt @ 7 Sep, 2008 - 12:08 PM) *

The way the program is written nothing will be printed out. The if statements do not have the { } brackets surrounding them so they will terminate as soon as they hit the next ';', anything after that will be eexcuted each time through the loop.

The loanBalance is also never initially set to anything besides 0, which means the while loops will never execute, the loan balance needs to be reset each time through the loop at each of the if statements.

The statement
loanBalance = loanAmount - monthlyPayment;
in each of the while loops should be
loanBalance = loanBalance - monthlyPayment;
in the first statement the loanBalance will be reset to 200000 resulting
in an infinite loop.

Also the if statements should start at if (i == 0) and go to if(i == 2)
in the for loop you have if(i == 3) will never be executed cause i will never be greater than 2


Thank you. I am confused about the brackets with the if statements. I did change the loanBalance statements. I am really confused at this tme. This asssignment is do today and I am getting more confused by the minute.
java
import java.io.*;
import java.util.Date;
import java.text.DecimalFormat;





public class mortgage4{

public static void main(String[] args){
//Declares and builds the variable of the loan amount
int loanAmount = 200000;
double loanBalance = 0;
double interestPaid = 0;
int loanTerm[] = {84, 180, 360};
double interest[] = {.0535, .0550, .0575};
double monthlyPayment = 0;
DecimalFormat money =new DecimalFormat("0.00");

//Starts array loop
for (int i = 0; i < 3; i++) {
//Declares formula
monthlyPayment = (loanAmount*(interest[i]/12)) / (1 - 1 /Math.pow((1 + interest[i]/12), loanTerm[i]));

//Displays loop with first mortgage and interest paid
if (i == 1){
monthlyPayment = (loanAmount*(interest[0]/12)) / (1 - 1 /Math.pow((1 + interest[0]/12), loanTerm[0]));
loanBalance = loanBalance - monthlyPayment;
interestPaid = monthlyPayment * interest[0];}

while (loanBalance > 0){

//Displays Mortgage Calculator with the first terms
System.out.println("Mortgage Calculator");
System.out.println("The loan amount is $200,000");
System.out.println("The term of the loan is " + loanTerm[0]);
System.out.println("The monthly payment is $" + money.format(monthlyPayment));
System.out.println("The loan balance is: $" + money.format(loanBalance));
System.out.println("The interest paid for the loan is $" + money.format(interestPaid));
System.out.println();

loanBalance = loanBalance - monthlyPayment;
interestPaid = monthlyPayment * interest[0];}

//Displays loop with second mortgage and interest paid
if (i == 2)
while (loanBalance > 0){
//Declares formulas
monthlyPayment = (loanAmount*(interest[1]/12)) / (1 - 1 /Math.pow((1 + interest[1]/12), loanTerm[1]));
loanBalance = loanBalance - monthlyPayment;
interestPaid = monthlyPayment * interest[1];

//Displays Mortgage Calculator with the first terms until balance equals zero
System.out.println("Mortgage Calculator");
System.out.println("The loan amount is $200,000");
System.out.println("The term of the loan is " + loanTerm[1]);
System.out.println("The monthly payment is $" + money.format(monthlyPayment));
System.out.println("The loan balance is: $" + money.format(loanBalance));
System.out.println("The interest paid for the loan is $" + money.format(interestPaid));
System.out.println();}

//Displays loop with third mortgage and interest paid
if (i == 3)
while (loanBalance > 0){
//Declares formulas
monthlyPayment = (loanAmount*(interest[2]/12)) / (1 - 1 /Math.pow((1 + interest[2]/12), loanTerm[2]));
loanBalance = loanBalance - monthlyPayment;
interestPaid = monthlyPayment * interest[2];

//Displays Mortgage Calculator with the first terms until balance equals zero
System.out.println("Mortgage Calculator");
System.out.println("The loan amount is $200,000");
System.out.println("The term of the loan is " + loanTerm[2]);
System.out.println("The monthly payment is $" + money.format(monthlyPayment));
System.out.println("The loan balance is: $" + money.format(loanBalance));
System.out.println("The interest paid for the loan is $" + money.format(interestPaid));
System.out.println();}
}
}
}

User is offlineProfile CardPM
+Quote Post

BigAnt
RE: Compiles But Does Nt Run.
7 Sep, 2008 - 12:58 PM
Post #5

May Your Swords Stay Sharp
Group Icon

Joined: 16 Aug, 2008
Posts: 2,384



Thanked: 95 times
Dream Kudos: 75
My Contributions
java
 
//Displays loop with first mortgage and interest paid
if (i == 1){
monthlyPayment = (loanAmount*(interest[0]/12)) / (1 - 1 /Math.pow((1 + interest[0]/12), loanTerm[0]));
loanBalance = loanBalance - monthlyPayment;
interestPaid = monthlyPayment * interest[0];}

while (loanBalance > 0){

//Displays Mortgage Calculator with the first terms
System.out.println("Mortgage Calculator");
System.out.println("The loan amount is $200,000");
System.out.println("The term of the loan is " + loanTerm[0]);
System.out.println("The monthly payment is $" + money.format(monthlyPayment));
System.out.println("The loan balance is: $" + money.format(loanBalance));
System.out.println("The interest paid for the loan is $" + money.format(interestPaid));
System.out.println();

loanBalance = loanBalance - monthlyPayment;
interestPaid = monthlyPayment * interest[0];}


java

if (i == 1) {
monthlyPayment = (loanAmount*(interest[0]/12)) / (1 - 1 /Math.pow((1 + interest[0]/12), loanTerm[0]));
loanBalance = loanBalance - monthlyPayment;
interestPaid = monthlyPayment * interest[0];
//} If the if end here the while loop will execute each time the for loop loops
while (loanBalance > 0){

//Displays Mortgage Calculator with the first terms
System.out.println("Mortgage Calculator");
System.out.println("The loan amount is $200,000");
System.out.println("The term of the loan is " + loanTerm[0]);
System.out.println("The monthly payment is $" + money.format(monthlyPayment));
System.out.println("The loan balance is: $" + money.format(loanBalance));
System.out.println("The interest paid for the loan is $" + money.format(interestPaid));
System.out.println();

loanBalance = loanBalance - monthlyPayment;
interestPaid = monthlyPayment * interest[0];

}// End while

}//End if The while loop will execute only with the if statement


The { } brackets surround what should be executed with the if statement. If you are confused about where to put them i would reccomended to label the { } brackets to indicate which ones are which and to indent the code to make it easier to follow.
These changes need to be done to all three if statements to get the loops to execute when you want them to.

Also change the boolean statements in the if statements to be from 0-2 insteaed of 1-3 or else all the loops will not execute.
User is offlineProfile CardPM
+Quote Post

jgear
RE: Compiles But Does Nt Run.
7 Sep, 2008 - 01:17 PM
Post #6

New D.I.C Head
*

Joined: 17 Aug, 2008
Posts: 47



Thanked: 1 times
My Contributions
QUOTE(BigAnt @ 7 Sep, 2008 - 01:58 PM) *

java
 
//Displays loop with first mortgage and interest paid
if (i == 1){
monthlyPayment = (loanAmount*(interest[0]/12)) / (1 - 1 /Math.pow((1 + interest[0]/12), loanTerm[0]));
loanBalance = loanBalance - monthlyPayment;
interestPaid = monthlyPayment * interest[0];}

while (loanBalance > 0){

//Displays Mortgage Calculator with the first terms
System.out.println("Mortgage Calculator");
System.out.println("The loan amount is $200,000");
System.out.println("The term of the loan is " + loanTerm[0]);
System.out.println("The monthly payment is $" + money.format(monthlyPayment));
System.out.println("The loan balance is: $" + money.format(loanBalance));
System.out.println("The interest paid for the loan is $" + money.format(interestPaid));
System.out.println();

loanBalance = loanBalance - monthlyPayment;
interestPaid = monthlyPayment * interest[0];}


CODE

if (i == 1) {
   monthlyPayment = (loanAmount*(interest[0]/12)) / (1 - 1 /Math.pow((1 + interest[0]/12), loanTerm[0]));
   loanBalance = loanBalance - monthlyPayment;
   interestPaid = monthlyPayment * interest[0];
//}  If the if end here the while loop will execute each time the for loop loops
   while (loanBalance > 0){

      //Displays Mortgage Calculator with the first terms
      System.out.println("Mortgage Calculator");
      System.out.println("The loan amount is $200,000");
      System.out.println("The term of the loan is " + loanTerm[0]);
      System.out.println("The monthly payment is $" + money.format(monthlyPayment));
      System.out.println("The loan balance is: $" + money.format(loanBalance));
      System.out.println("The interest paid for the loan is $" + money.format(interestPaid));
      System.out.println();

      loanBalance = loanBalance - monthlyPayment;
      interestPaid = monthlyPayment * interest[0];

}// End while

}//End if   The while loop will execute only with the if statement


The { } brackets surround what should be executed with the if statement. If you are confused about where to put them i would reccomended to label the { } brackets to indicate which ones are which and to indent the code to make it easier to follow.
These changes need to be done to all three if statements to get the loops to execute when you want them to.

Also change the boolean statements in the if statements to be from 0-2 insteaed of 1-3 or else all the loops will not execute.


Ok. By the way I appreciate your patience. I think I did what you requested. Now I get the error "cannot resolve symbol symbol: variable1 if(i==2){}
java
import java.io.*;
import java.util.Date;
import java.text.DecimalFormat;





public class mortgage4{

public static void main(String[] args){
//Declares and builds the variable of the loan amount
int loanAmount = 200000;
double loanBalance = 0;
double interestPaid = 0;
int loanTerm[] = {84, 180, 360};
double interest[] = {.0535, .0550, .0575};
double monthlyPayment = 0;
DecimalFormat money =new DecimalFormat("0.00");

//Starts array loop
for (int i = 0; i < 2; i++) {
//Declares formula
monthlyPayment = (loanAmount*(interest[i]/12)) / (1 - 1 /Math.pow((1 + interest[i]/12), loanTerm[i]));

//Displays loop with first mortgage and interest paid
if (i == 0){
monthlyPayment = (loanAmount*(interest[0]/12)) / (1 - 1 /Math.pow((1 + interest[0]/12), loanTerm[0]));
loanBalance = loanBalance - monthlyPayment;
interestPaid = monthlyPayment * interest[0];}

while (loanBalance > 0){

//Displays Mortgage Calculator with the first terms
System.out.println("Mortgage Calculator");
System.out.println("The loan amount is $200,000");
System.out.println("The term of the loan is " + loanTerm[0]);
System.out.println("The monthly payment is $" + money.format(monthlyPayment));
System.out.println("The loan balance is: $" + money.format(loanBalance));
System.out.println("The interest paid for the loan is $" + money.format(interestPaid));
System.out.println();

loanBalance = loanBalance - monthlyPayment;
interestPaid = monthlyPayment * interest[0];}

//Displays loop with second mortgage and interest paid
if (i == 1){}
while (loanBalance > 0){
//Declares formulas
monthlyPayment = (loanAmount*(interest[1]/12)) / (1 - 1 /Math.pow((1 + interest[1]/12), loanTerm[1]));
loanBalance = loanBalance - monthlyPayment;
interestPaid = monthlyPayment * interest[1];}

//Displays Mortgage Calculator with the first terms until balance equals zero
System.out.println("Mortgage Calculator");
System.out.println("The loan amount is $200,000");
System.out.println("The term of the loan is " + loanTerm[1]);
System.out.println("The monthly payment is $" + money.format(monthlyPayment));
System.out.println("The loan balance is: $" + money.format(loanBalance));
System.out.println("The interest paid for the loan is $" + money.format(interestPaid));
System.out.println();}

//Displays loop with third mortgage and interest paid
if (i == 2){}
while (loanBalance > 0){
//Declares formulas
monthlyPayment = (loanAmount*(interest[2]/12)) / (1 - 1 /Math.pow((1 + interest[2]/12), loanTerm[2]));
loanBalance = loanBalance - monthlyPayment;
interestPaid = monthlyPayment * interest[2];

//Displays Mortgage Calculator with the first terms until balance equals zero
System.out.println("Mortgage Calculator");
System.out.println("The loan amount is $200,000");
System.out.println("The term of the loan is " + loanTerm[2]);
System.out.println("The monthly payment is $" + money.format(monthlyPayment));
System.out.println("The loan balance is: $" + money.format(loanBalance));
System.out.println("The interest paid for the loan is $" + money.format(interestPaid));
System.out.println();}
}
}

Edited to add =java to the code tag... that might help to align the {}

This post has been edited by pbl: 7 Sep, 2008 - 06:09 PM
User is offlineProfile CardPM
+Quote Post

BigAnt
RE: Compiles But Does Nt Run.
7 Sep, 2008 - 01:52 PM
Post #7

May Your Swords Stay Sharp
Group Icon

Joined: 16 Aug, 2008
Posts: 2,384



Thanked: 95 times
Dream Kudos: 75
My Contributions
You have to put the statements you want executed when the if boolean statement is true between the { } braces. If you have if(i == 0) { } then no statements will be executed when the if statements is true because there are no statements between the { } braces. The first if statement is shown in my previous posted code. Follow this to format the last 2 if statements.

After that at the beginning of each if statement (before anything else) you should set
loanBalance = loanAmmount;
to initialize the loanBalance before the while loop.


This post has been edited by BigAnt: 7 Sep, 2008 - 01:53 PM
User is offlineProfile CardPM
+Quote Post

jgear
RE: Compiles But Does Nt Run.
7 Sep, 2008 - 02:00 PM
Post #8

New D.I.C Head
*

Joined: 17 Aug, 2008
Posts: 47



Thanked: 1 times
My Contributions
QUOTE(BigAnt @ 7 Sep, 2008 - 02:52 PM) *

You have to put the statements you want executed when the if boolean statement is true between the { } braces. If you have if(i == 0) { } then no statements will be executed when the if statements is true because there are no statements between the { } braces. The first if statement is shown in my previous posted code. Follow this to format the last 2 if statements.

After that at the beginning of each if statement (before anything else) you should set
loanBalance = loanAmmount;
to initialize the loanBalance before the while loop.


Thank you very much. I think I got it.

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 7/3/09 11:50PM

Live Java Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month