New to java need help with code been up all night.
I started this program three days ago the books have me confused trying to
keep my wits about what I am trying to do.
Here are my errors and my code:
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.NoSuchMethodError: main
C:\POS407\JavaPrograms\classes>REM Change directory back to the bin
directory
C:\POS407\JavaPrograms\classes>cd ..\bin
C:\POS407\JavaPrograms\bin>
here is my code:
//*******************************************************
// Code for storing loan information and printing an
*
// amortization report.
*
//*******************************************************
import java.io.*;
import java.text.DecimalFormat;
public class EverettMortgagePayment_CR4
{
private double loanAmount; // Loan Amount
private double interestRate; // Annual Interest Rate
private double loanBalance; // Monthly Balance
private double term; // Payment Term
private double payment; // Monthly Payment
private int loanYears; // Years of Loan
//****************************************************
// The beginning code uses three parameters:
*
// which is the loan balance, the annual interest
*
// rate, and term in years of the loan.
*
// These values are stored in the corresponding
*
// code of the program. The private calcPayment code
*
// is then executed.
*
//****************************************************
public EverettMortgagePayment_CR4(double loan, double rate, int years)
{
loanAmount = loan;
loanBalance = loan;
interestRate = rate;
loanYears = years;
calcPayment();
}
//******************************************************
// This area is used to calculate the amount paid per
*
// month. The result put in the payment field. Then it
*
// save for use later
*
//******************************************************
private void calcPayment()
{
// Calculate value of Term
term =
Math.pow((1+interestRate/12.0), 12.0 * loanYears);
// Calculate monthly payment
payment =
(loanAmount * interestRate/12.0 * term) / (term - 1);
}
//********************************************************
// The getNumberOfPayments is a mathmatical equation
*
// allows for the number of loan payments over the years.
*
//********************************************************
public int getNumberOfPayments()
{
return 12 * loanYears;
}
//*********************************************************
// The makeReport saves the amortization report to a file
*
// that is created by the filename argumentin the code
*
//*********************************************************
public void makeReport(String filename) throws IOException
{
double monthlyInterest; // The monthly interest rate
double principal; // The amount of principal
// Create a DecimalFormat object for output formatting.
DecimalFormat dollar = new DecimalFormat("#,##0.00");
// Create objects necessary for file output.
FileWriter fwriter = new FileWriter(filename);
PrintWriter outputFile = new PrintWriter(fwriter);
// Print monthly payment amount.
outputFile.println("Monthly Payment: $"
+ dollar.format(payment));
// Print the report header.
outputFile.println("Month\tInterest\tPrincipal\tBalance");
outputFile.println("-----------------------------------"
+ "--------------");
// Display the amortization table.
for (int month = 1; month <= getNumberOfPayments(); month++)
{
// Calculate monthly interest.
monthlyInterest = interestRate / 12.0 * loanBalance;
if (month != getNumberOfPayments())
{
// Calculate payment applied to principal
principal = payment - monthlyInterest;
}
else // This is the last month.
{
principal = loanBalance;
payment = loanBalance + monthlyInterest;
}
// Calculate the new loan balance.
loanBalance -= principal;
// Display a line of data.
outputFile.println(month
+ "\t"
+ dollar.format(monthlyInterest)
+ "\t\t"
+ dollar.format(principal)
+ "\t\t"
+ dollar.format(loanBalance));
}
// Close the file.
outputFile.close();
}
//********************************************************
// The getLoanAmount code returns the loan amount.
*
//********************************************************
public double getLoanAmount()
{
return loanAmount;
}
//********************************************************
// The getInterestRate code returns the interest rate.
*
//********************************************************
public double getInterestRate()
{
return interestRate;
}
//********************************************************
// The getLoanYears code returns the years of the loan.
*
//********************************************************
public int getLoanYears()
{
return loanYears;
}
}