The following is the error. The format is correct but I cannot find the code
problem
C:\POS407\JavaPrograms\bin>run
C:\POS407\JavaPrograms\bin>REM Change directory to the classes directory
C:\POS407\JavaPrograms\bin>cd ..\classes
C:\POS407\JavaPrograms\classes>REM Execute Java program
C:\POS407\JavaPrograms\classes>java -classpath . EverettMortgagePayment_CR4
Exception in thread "main" java.lang.NoClassDefFoundError:
EverettMortgagePaymen
t_CR4
C:\POS407\JavaPrograms\classes>REM Change directory back to the bin
directory
C:\POS407\JavaPrograms\classes>cd ..\bin
C:\POS407\JavaPrograms\bin>
package mortgage;
import java.text.*;
import java.util.*;
import java.io.*;
public class EverettMortgagePayment_CR4
{
public static void main(String[] args) throws IOException
{
NumberFormat formatter =
NumberFormat.getCurrencyInstance(Locale.US);
double mortgagePrinciple = 200000.00;
double interestRate = .0575;
double interest = 0;
int termMonths = 360;
double months = 360;
double temp = 0;
double monthlyPayment = 0;
double interestPaid = 0;
double principalPaid = 0;
double mortgageBalance = 200000.00;
//formula to calculate monthly payment amount
monthlyPayment = (mortgagePrinciple * (interestRate / 12)) / (1 - 1
/
Math.pow((1 + interestRate / 12), termMonths));
//Prints the mortgage calculator
System.out.println("Mortgage Calculator");
System.out.println("Your payment for a " +
(formatter.format(mortgagePrinciple)) +
" mortgage over a term of");
System.out.println((termMonths/12) +
" years with an interest rate of " + (interestRate * 100) + "% will
be "
+ (formatter.format(monthlyPayment)) + " a month.");
System.out.println();
System.out.println("Press Enter to Continue.");
System.in.read ();
// Starts loop statement
// declares formula for loan balance and interest paid.
while (termMonths > 0)
{
// reduces the term one month at a time
months --;
/* calculates the interest paid and resets the mortgage
balance to reflect payment.*/
temp = (1 - 1 / Math.pow((1 + interestRate / 12), months));
interestPaid = monthlyPayment * temp;
mortgageBalance = mortgagePrinciple - monthlyPayment +
interestPaid;
//Displays the payment amount, mortgage balance, and interest
paid.
System.out.println("After a payment of: " +
formatter.format(monthlyPayment));
System.out.println("The current balance of your mortgage is: " +
formatter.format(mortgageBalance));
System.out.println("This months interest paid on the mortgage
is: "
+ formatter.format(interestPaid));
System.out.println();
//sets a new mortgage amount reflecting the payment.
mortgagePrinciple = mortgageBalance;
//Pauses screen
try
{
Thread.sleep(1500);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}//End of while loop
}//End of Main
}//End of EverettMortgagePayment_CR4
cp - 31 Jul 2006 10:29 GMT
Andrew Thompson - 31 Jul 2006 11:44 GMT
..
> C:\POS407\JavaPrograms\bin>cd ..\classes
>
[quoted text clipped - 4 lines]
> EverettMortgagePaymen
> t_CR4
This command is expecting to find the class at
classes/EverettMortgagePayment_CR4.class
.., whereas this..
> package mortgage;
..indicates the class is actually located at..
classes/mortgage.EverettMortgagePayment_CR4.class
To fix the problem, try invoking java like this
(line wrapped for clarity)..
C:\POS407\JavaPrograms\classes>java
-classpath .
mortgage.EverettMortgagePayment_CR4
HTH
Andrew T.
Andrew Thompson - 31 Jul 2006 11:47 GMT
> ..indicates the class is actually located at..
>
> classes/mortgage.EverettMortgagePayment_CR4.class
Oops! Try..
classes/mortgage/EverettMortgagePayment_CR4.class
Andrew T.
ge0rge - 31 Jul 2006 12:14 GMT
...
> C:\POS407\JavaPrograms\classes>java -classpath . EverettMortgagePayment_CR4
> Exception in thread "main" java.lang.NoClassDefFoundError:
> EverettMortgagePaymen
> t_CR4
...
> package mortgage;
It's to do with the package statement.
In C:\POS407\JavaPrograms\classes, create the subdirectory mortgage and
stick the EverettMortgagePayment_CR4 class in it
then cd to directory classes and issue
java -classpath . mortgage.EverettMortgagePayment_CR4
See Roedy Green's page on classpath
http://mindprod.com/jgloss/classpath.html

Signature
Everyone who comes in here wants three things:
(1) They want it quick.
(2) They want it good.
(3) They want it cheap.
I tell 'em to pick two and call me back.
-- sign on the back wall of a small printing company