Harbatuk
asked on
Getting error- Can not resolve symbol
I am getting an error message "Can not resolve symbol" on line 217 and 219.
//PROGRAMMER:
//CLASS:
//FILE: MCEVENT.JAVA
//INSTRUCTOR:
//DATE:
//PROGRAM DESCRIPTION:
// Write a Java program using a graphical user interface
// that calculates and displays the mortgage payment amount
// from user input of the amount of the mortgage, the term
// f the mortgage, and the interest rate of the mortgage.
// Allow the user to loop back and enter new data or quit.
// Insert comments in the program to document the program.
// Note: This program was written without a graphical user interface in POS406.
////////////////////////// ////////// ////////// ////////// ////////// ////////// ///////
import javax.swing.*;
import java.awt.event.*;
//import java.awt.lang.*;
import java.text.NumberFormat; // Number format utility
import java.util.Locale; // Local currency format information
import java.io.*;
//INITIALIZAION OF CLASS
//public class mcEvent implements ActionListener,ItemListene r, Runnable{
public class mcEvent implements ActionListener,ItemListene r{
MortgageCalculator gui;
ReadWriteTextFile dosScreen;
public mcEvent(MortgageCalculator in){
gui=in;
}
public mcEvent(ReadWriteTextFile in2){
dosScreen=in2;
}
// NumberFormat doCurrencyFormat;
NumberFormat doCurrencyFormat = NumberFormat.getCurrencyIn stance(Loc ale.US);
public void actionPerformed(ActionEven t event){
String command = event.getActionCommand();
if (command =="Calculate")
calculate();
else if (command =="Clear")
clearAllFields();
else if (command =="InterestRate File");
ReadWriteTextFile();
//else CalcForCheckBoxSelection() ;
}
//CALCULATE METHOD
void calculate(){
int termArray=0;
double termYears=0.0;
double termRate=0.0;
double termMonRate=0.0;
double loanMonths;
double loanPaymentAmount;
double countRowNum;
double principleLoan;
double interestLoan;
double principle;
double loanTime;
double monInterest;
double totalInterest=1;
double totalPrinciple =0.0;
double actualPrinciple;
double[][] mortTermData ={ //Choice of mortgage terms
{7.0,5.35},
{15.0,5.5},
{30.0,5.75}
};
termArray = gui.cboMortTerm.getSelecte dIndex();
termYears =mortTermData[termArray][0 ];
termRate = mortTermData[termArray][1] ;
//DETERMINE MONTHLY INTEREST
termMonRate = termRate/(12*100);
//GET TOTAL YEARS IN MONTHS
loanMonths = termYears*12;
//GET USER ENTRY FROM LOAN AMOUNT TEXTBOX
principleLoan=Double.parse Double(gui .tfLoanAmt .getText() );
//CALCULATE LOAN PAYMENT AMOUNT UTILIZING DATA INPUT FROM USER
loanPaymentAmount = principleLoan*(termMonRate /(1-Math.p ow((1 + termMonRate),-loanMonths)) );
//OUTPUT CALCULATIONT TO PAYMENT BOX
gui.tfMonPayment.setText(d oCurrencyF ormat.form at(loanPay mentAmount ));
countRowNum = gui.amortizModel.getRowCou nt();
while(countRowNum >0)
{
gui.amortizModel.removeRow (gui.amort izModel.ge tRowCount( )-1);
countRowNum = gui.amortizModel.getRowCou nt();
}
for (int i=1;principleLoan>0;i++)
{
monInterest = principleLoan * termMonRate;
principle =loanPaymentAmount -monInterest;
actualPrinciple= principleLoan-principle;
totalInterest *= monInterest;
gui.amortizModel.addRow(ne w Object[]
{String.valueOf(i), doCurrencyFormat.format(lo anPaymentA mount)
, doCurrencyFormat.format(pr inciple)
,doCurrencyFormat.format(m onInterest )
, doCurrencyFormat.format(ac tualPrinci ple)
, doCurrencyFormat.format(to talInteres t)});
principleLoan = actualPrinciple;
}
gui.clearButton.setEnabled (true);
}
void CalcForCheckBoxSelection()
{
double principle;
double principleLoan;
double actualPrinciple;
double loanAmt=0.0;
double userMortTerm=0.0;
double loanMonths;
double userMortRate=0.0;
double termMonRate =0.0;
double monInterest =0.0;
double totalInterest=1;
double loanPaymentAmount;
int countRowNum;
//DETERMINE MONTHLY INTEREST
userMortRate = Double.parseDouble (gui.tfuserMortRate.getTex t());
termMonRate = userMortRate/(12*100);
//GET TOTAL YEARS IN MONTHS
userMortTerm =Double.parseDouble(gui.tf userMortTe rm.getText ());
loanMonths = userMortTerm*12;
//GET USER ENTRY FROM LOAN AMOUNT TEXTBOX
principleLoan=Double.parse Double(gui .tfLoanAmt .getText() );
//CALCULATE LOAN PAYMENT AMOUNT UTILIZING DATA INPUT FROM USER
loanPaymentAmount = principleLoan*(termMonRate /(1-Math.p ow((1 + termMonRate),-loanMonths)) );
//OUTPUT CALCULATIONT TO PAYMENT BOX
gui.tfMonPayment.setText(d oCurrencyF ormat.form at(loanPay mentAmount ));
countRowNum = gui.amortizModel.getRowCou nt();
while(countRowNum >0)
{
gui.amortizModel.removeRow (gui.amort izModel.ge tRowCount( )-1);
countRowNum = gui.amortizModel.getRowCou nt();
}
for (int i=1;principleLoan>0;i++)
{
monInterest = principleLoan * termMonRate;
principle =loanPaymentAmount -monInterest;
actualPrinciple= principleLoan-principle;
totalInterest *= monInterest;
gui.amortizModel.addRow(ne w Object[]
{String.valueOf(i), doCurrencyFormat.format(lo anPaymentA mount)
, doCurrencyFormat.format(pr inciple)
,doCurrencyFormat.format(m onInterest )
, doCurrencyFormat.format(ac tualPrinci ple)
, doCurrencyFormat.format(to talInteres t)});
principleLoan = actualPrinciple;
}
}
//CLEAR FIELD METHOD
void clearAllFields()
{
int countRowNum =0;
//CLEARING ALL FIELD
gui.tfLoanAmt.setText(null );
gui.tfMonPayment.setText(n ull);
countRowNum= gui.amortizModel.getRowCou nt();
while(countRowNum >0)
{
gui.amortizModel.removeRow (gui.amort izModel.ge tRowCount( ) - 1);
countRowNum = gui.amortizModel.getRowCou nt();
}
gui.clearButton.setEnabled (false);
}
//public class ReadWriteTextFile ()
void ReadWriteTextFile ()
{
int fileData;
File inputFile = new File("C:\\Kathy.txt");
try{
FileInputStream aFile = new FileInputStream(inputFile) ;
} catch (IOException e) {
System.out.print("Could not read file");
}
while((fileData = aFile.read())>0)
System.out.print((char)fil eData);
aFile.close();
}
public void itemStateChanged(ItemEvent evt)
{
gui.userSelectBox = (JCheckBox)evt.getItemSele ctable();
if (gui.userSelectBox.isSelec ted()){
gui.cboMortTerm.setEnabled (false);
CalcForCheckBoxSelection() ; }
else {
gui.cboMortTerm.setEnabled (true);
JComboBox term = (JComboBox)evt.getSource() ;
}
}
}
//PROGRAMMER:
//CLASS:
//FILE: MCEVENT.JAVA
//INSTRUCTOR:
//DATE:
//PROGRAM DESCRIPTION:
// Write a Java program using a graphical user interface
// that calculates and displays the mortgage payment amount
// from user input of the amount of the mortgage, the term
// f the mortgage, and the interest rate of the mortgage.
// Allow the user to loop back and enter new data or quit.
// Insert comments in the program to document the program.
// Note: This program was written without a graphical user interface in POS406.
//////////////////////////
import javax.swing.*;
import java.awt.event.*;
//import java.awt.lang.*;
import java.text.NumberFormat; // Number format utility
import java.util.Locale; // Local currency format information
import java.io.*;
//INITIALIZAION OF CLASS
//public class mcEvent implements ActionListener,ItemListene
public class mcEvent implements ActionListener,ItemListene
MortgageCalculator gui;
ReadWriteTextFile dosScreen;
public mcEvent(MortgageCalculator
gui=in;
}
public mcEvent(ReadWriteTextFile in2){
dosScreen=in2;
}
// NumberFormat doCurrencyFormat;
NumberFormat doCurrencyFormat = NumberFormat.getCurrencyIn
public void actionPerformed(ActionEven
String command = event.getActionCommand();
if (command =="Calculate")
calculate();
else if (command =="Clear")
clearAllFields();
else if (command =="InterestRate File");
ReadWriteTextFile();
//else CalcForCheckBoxSelection()
}
//CALCULATE METHOD
void calculate(){
int termArray=0;
double termYears=0.0;
double termRate=0.0;
double termMonRate=0.0;
double loanMonths;
double loanPaymentAmount;
double countRowNum;
double principleLoan;
double interestLoan;
double principle;
double loanTime;
double monInterest;
double totalInterest=1;
double totalPrinciple =0.0;
double actualPrinciple;
double[][] mortTermData ={ //Choice of mortgage terms
{7.0,5.35},
{15.0,5.5},
{30.0,5.75}
};
termArray = gui.cboMortTerm.getSelecte
termYears =mortTermData[termArray][0
termRate = mortTermData[termArray][1]
//DETERMINE MONTHLY INTEREST
termMonRate = termRate/(12*100);
//GET TOTAL YEARS IN MONTHS
loanMonths = termYears*12;
//GET USER ENTRY FROM LOAN AMOUNT TEXTBOX
principleLoan=Double.parse
//CALCULATE LOAN PAYMENT AMOUNT UTILIZING DATA INPUT FROM USER
loanPaymentAmount = principleLoan*(termMonRate
//OUTPUT CALCULATIONT TO PAYMENT BOX
gui.tfMonPayment.setText(d
countRowNum = gui.amortizModel.getRowCou
while(countRowNum >0)
{
gui.amortizModel.removeRow
countRowNum = gui.amortizModel.getRowCou
}
for (int i=1;principleLoan>0;i++)
{
monInterest = principleLoan * termMonRate;
principle =loanPaymentAmount -monInterest;
actualPrinciple= principleLoan-principle;
totalInterest *= monInterest;
gui.amortizModel.addRow(ne
{String.valueOf(i), doCurrencyFormat.format(lo
, doCurrencyFormat.format(pr
,doCurrencyFormat.format(m
, doCurrencyFormat.format(ac
, doCurrencyFormat.format(to
principleLoan = actualPrinciple;
}
gui.clearButton.setEnabled
}
void CalcForCheckBoxSelection()
{
double principle;
double principleLoan;
double actualPrinciple;
double loanAmt=0.0;
double userMortTerm=0.0;
double loanMonths;
double userMortRate=0.0;
double termMonRate =0.0;
double monInterest =0.0;
double totalInterest=1;
double loanPaymentAmount;
int countRowNum;
//DETERMINE MONTHLY INTEREST
userMortRate = Double.parseDouble (gui.tfuserMortRate.getTex
termMonRate = userMortRate/(12*100);
//GET TOTAL YEARS IN MONTHS
userMortTerm =Double.parseDouble(gui.tf
loanMonths = userMortTerm*12;
//GET USER ENTRY FROM LOAN AMOUNT TEXTBOX
principleLoan=Double.parse
//CALCULATE LOAN PAYMENT AMOUNT UTILIZING DATA INPUT FROM USER
loanPaymentAmount = principleLoan*(termMonRate
//OUTPUT CALCULATIONT TO PAYMENT BOX
gui.tfMonPayment.setText(d
countRowNum = gui.amortizModel.getRowCou
while(countRowNum >0)
{
gui.amortizModel.removeRow
countRowNum = gui.amortizModel.getRowCou
}
for (int i=1;principleLoan>0;i++)
{
monInterest = principleLoan * termMonRate;
principle =loanPaymentAmount -monInterest;
actualPrinciple= principleLoan-principle;
totalInterest *= monInterest;
gui.amortizModel.addRow(ne
{String.valueOf(i), doCurrencyFormat.format(lo
, doCurrencyFormat.format(pr
,doCurrencyFormat.format(m
, doCurrencyFormat.format(ac
, doCurrencyFormat.format(to
principleLoan = actualPrinciple;
}
}
//CLEAR FIELD METHOD
void clearAllFields()
{
int countRowNum =0;
//CLEARING ALL FIELD
gui.tfLoanAmt.setText(null
gui.tfMonPayment.setText(n
countRowNum= gui.amortizModel.getRowCou
while(countRowNum >0)
{
gui.amortizModel.removeRow
countRowNum = gui.amortizModel.getRowCou
}
gui.clearButton.setEnabled
}
//public class ReadWriteTextFile ()
void ReadWriteTextFile ()
{
int fileData;
File inputFile = new File("C:\\Kathy.txt");
try{
FileInputStream aFile = new FileInputStream(inputFile)
} catch (IOException e) {
System.out.print("Could not read file");
}
while((fileData = aFile.read())>0)
System.out.print((char)fil
aFile.close();
}
public void itemStateChanged(ItemEvent
{
gui.userSelectBox = (JCheckBox)evt.getItemSele
if (gui.userSelectBox.isSelec
gui.cboMortTerm.setEnabled
CalcForCheckBoxSelection()
else {
gui.cboMortTerm.setEnabled
JComboBox term = (JComboBox)evt.getSource()
}
}
}
ASKER
Thank you!!! This worked. :-)
ASKER
My next question is......... how do I create this data (from data file)into an array for manipulation.
The data file is named: Kathy.txt.
Contents are very small. 5.37 5.50 5.75
This method is the ReadWriteTextFile();
void ReadWriteTextFile ()
{
int fileData;
File inputFile = new File("C:\\Kathy.txt");
try{
FileInputStream aFile = new FileInputStream(inputFile) ;
while((fileData = aFile.read())>0)
System.out.print((char)fil eData);
aFile.close();
} catch (IOException e) {
System.out.print("Could not read file");
}
}
See below all of the code.
//PROGRAMMER:
//CLASS:
//FILE: MCEVENT.JAVA
//INSTRUCTOR:
//DATE:
//PROGRAM DESCRIPTION:
// Write a Java program using a graphical user interface
// that calculates and displays the mortgage payment amount
// from user input of the amount of the mortgage, the term
// f the mortgage, and the interest rate of the mortgage.
// Allow the user to loop back and enter new data or quit.
// Insert comments in the program to document the program.
// Note: This program was written without a graphical user interface in POS406.
////////////////////////// ////////// ////////// ////////// ////////// ////////// ///////
import javax.swing.*;
import java.awt.event.*;
//import java.awt.lang.*;
import java.text.NumberFormat; // Number format utility
import java.util.Locale; // Local currency format information
import java.io.*;
//INITIALIZAION OF CLASS
//public class mcEvent implements ActionListener,ItemListene r, Runnable{
public class mcEvent implements ActionListener,ItemListene r{
MortgageCalculator gui;
ReadWriteTextFile dosScreen;
public mcEvent(MortgageCalculator in){
gui=in;
}
public mcEvent(ReadWriteTextFile in2){
dosScreen=in2;
}
// NumberFormat doCurrencyFormat;
NumberFormat doCurrencyFormat = NumberFormat.getCurrencyIn stance(Loc ale.US);
public void actionPerformed(ActionEven t event){
String command = event.getActionCommand();
if (command =="Calculate")
calculate();
else if (command =="Clear")
clearAllFields();
else if (command =="InterestRate File");
ReadWriteTextFile();
//else CalcForCheckBoxSelection() ;
}
//CALCULATE METHOD
void calculate(){
int termArray=0;
double termYears=0.0;
double termRate=0.0;
double termMonRate=0.0;
double loanMonths;
double loanPaymentAmount;
double countRowNum;
double principleLoan;
double interestLoan;
double principle;
double loanTime;
double monInterest;
double totalInterest=1;
double totalPrinciple =0.0;
double actualPrinciple;
double[][] mortTermData ={ //Choice of mortgage terms
{7.0,5.35},
{15.0,5.5},
{30.0,5.75}
};
termArray = gui.cboMortTerm.getSelecte dIndex();
termYears =mortTermData[termArray][0 ];
termRate = mortTermData[termArray][1] ;
//DETERMINE MONTHLY INTEREST
termMonRate = termRate/(12*100);
//GET TOTAL YEARS IN MONTHS
loanMonths = termYears*12;
//GET USER ENTRY FROM LOAN AMOUNT TEXTBOX
principleLoan=Double.parse Double(gui .tfLoanAmt .getText() );
//CALCULATE LOAN PAYMENT AMOUNT UTILIZING DATA INPUT FROM USER
loanPaymentAmount = principleLoan*(termMonRate /(1-Math.p ow((1 + termMonRate),-loanMonths)) );
//OUTPUT CALCULATIONT TO PAYMENT BOX
gui.tfMonPayment.setText(d oCurrencyF ormat.form at(loanPay mentAmount ));
countRowNum = gui.amortizModel.getRowCou nt();
while(countRowNum >0)
{
gui.amortizModel.removeRow (gui.amort izModel.ge tRowCount( )-1);
countRowNum = gui.amortizModel.getRowCou nt();
}
for (int i=1;principleLoan>0;i++)
{
monInterest = principleLoan * termMonRate;
principle =loanPaymentAmount -monInterest;
actualPrinciple= principleLoan-principle;
totalInterest *= monInterest;
gui.amortizModel.addRow(ne w Object[]
{String.valueOf(i), doCurrencyFormat.format(lo anPaymentA mount)
, doCurrencyFormat.format(pr inciple)
,doCurrencyFormat.format(m onInterest )
, doCurrencyFormat.format(ac tualPrinci ple)
, doCurrencyFormat.format(to talInteres t)});
principleLoan = actualPrinciple;
}
gui.clearButton.setEnabled (true);
}
void CalcForCheckBoxSelection()
{
double principle;
double principleLoan;
double actualPrinciple;
double loanAmt=0.0;
double userMortTerm=0.0;
double loanMonths;
double userMortRate=0.0;
double termMonRate =0.0;
double monInterest =0.0;
double totalInterest=1;
double loanPaymentAmount;
int countRowNum;
//DETERMINE MONTHLY INTEREST
userMortRate = Double.parseDouble (gui.tfuserMortRate.getTex t());
termMonRate = userMortRate/(12*100);
//GET TOTAL YEARS IN MONTHS
userMortTerm =Double.parseDouble(gui.tf userMortTe rm.getText ());
loanMonths = userMortTerm*12;
//GET USER ENTRY FROM LOAN AMOUNT TEXTBOX
principleLoan=Double.parse Double(gui .tfLoanAmt .getText() );
//CALCULATE LOAN PAYMENT AMOUNT UTILIZING DATA INPUT FROM USER
loanPaymentAmount = principleLoan*(termMonRate /(1-Math.p ow((1 + termMonRate),-loanMonths)) );
//OUTPUT CALCULATIONT TO PAYMENT BOX
gui.tfMonPayment.setText(d oCurrencyF ormat.form at(loanPay mentAmount ));
countRowNum = gui.amortizModel.getRowCou nt();
while(countRowNum >0)
{
gui.amortizModel.removeRow (gui.amort izModel.ge tRowCount( )-1);
countRowNum = gui.amortizModel.getRowCou nt();
}
for (int i=1;principleLoan>0;i++)
{
monInterest = principleLoan * termMonRate;
principle =loanPaymentAmount -monInterest;
actualPrinciple= principleLoan-principle;
totalInterest *= monInterest;
gui.amortizModel.addRow(ne w Object[]
{String.valueOf(i), doCurrencyFormat.format(lo anPaymentA mount)
, doCurrencyFormat.format(pr inciple)
,doCurrencyFormat.format(m onInterest )
, doCurrencyFormat.format(ac tualPrinci ple)
, doCurrencyFormat.format(to talInteres t)});
principleLoan = actualPrinciple;
}
}
//CLEAR FIELD METHOD
void clearAllFields()
{
int countRowNum =0;
//CLEARING ALL FIELD
gui.tfLoanAmt.setText(null );
gui.tfMonPayment.setText(n ull);
countRowNum= gui.amortizModel.getRowCou nt();
while(countRowNum >0)
{
gui.amortizModel.removeRow (gui.amort izModel.ge tRowCount( ) - 1);
countRowNum = gui.amortizModel.getRowCou nt();
}
gui.clearButton.setEnabled (false);
}
//public class ReadWriteTextFile ()
void ReadWriteTextFile ()
{
int fileData;
File inputFile = new File("C:\\Kathy.txt");
try{
FileInputStream aFile = new FileInputStream(inputFile) ;
while((fileData = aFile.read())>0)
System.out.print((char)fil eData);
aFile.close();
} catch (IOException e) {
System.out.print("Could not read file");
}
}
public void itemStateChanged(ItemEvent evt)
{
gui.userSelectBox = (JCheckBox)evt.getItemSele ctable();
if (gui.userSelectBox.isSelec ted()){
gui.cboMortTerm.setEnabled (false);
CalcForCheckBoxSelection() ; }
else {
gui.cboMortTerm.setEnabled (true);
JComboBox term = (JComboBox)evt.getSource() ;
}
}
}
The data file is named: Kathy.txt.
Contents are very small. 5.37 5.50 5.75
This method is the ReadWriteTextFile();
void ReadWriteTextFile ()
{
int fileData;
File inputFile = new File("C:\\Kathy.txt");
try{
FileInputStream aFile = new FileInputStream(inputFile)
while((fileData = aFile.read())>0)
System.out.print((char)fil
aFile.close();
} catch (IOException e) {
System.out.print("Could not read file");
}
}
See below all of the code.
//PROGRAMMER:
//CLASS:
//FILE: MCEVENT.JAVA
//INSTRUCTOR:
//DATE:
//PROGRAM DESCRIPTION:
// Write a Java program using a graphical user interface
// that calculates and displays the mortgage payment amount
// from user input of the amount of the mortgage, the term
// f the mortgage, and the interest rate of the mortgage.
// Allow the user to loop back and enter new data or quit.
// Insert comments in the program to document the program.
// Note: This program was written without a graphical user interface in POS406.
//////////////////////////
import javax.swing.*;
import java.awt.event.*;
//import java.awt.lang.*;
import java.text.NumberFormat; // Number format utility
import java.util.Locale; // Local currency format information
import java.io.*;
//INITIALIZAION OF CLASS
//public class mcEvent implements ActionListener,ItemListene
public class mcEvent implements ActionListener,ItemListene
MortgageCalculator gui;
ReadWriteTextFile dosScreen;
public mcEvent(MortgageCalculator
gui=in;
}
public mcEvent(ReadWriteTextFile in2){
dosScreen=in2;
}
// NumberFormat doCurrencyFormat;
NumberFormat doCurrencyFormat = NumberFormat.getCurrencyIn
public void actionPerformed(ActionEven
String command = event.getActionCommand();
if (command =="Calculate")
calculate();
else if (command =="Clear")
clearAllFields();
else if (command =="InterestRate File");
ReadWriteTextFile();
//else CalcForCheckBoxSelection()
}
//CALCULATE METHOD
void calculate(){
int termArray=0;
double termYears=0.0;
double termRate=0.0;
double termMonRate=0.0;
double loanMonths;
double loanPaymentAmount;
double countRowNum;
double principleLoan;
double interestLoan;
double principle;
double loanTime;
double monInterest;
double totalInterest=1;
double totalPrinciple =0.0;
double actualPrinciple;
double[][] mortTermData ={ //Choice of mortgage terms
{7.0,5.35},
{15.0,5.5},
{30.0,5.75}
};
termArray = gui.cboMortTerm.getSelecte
termYears =mortTermData[termArray][0
termRate = mortTermData[termArray][1]
//DETERMINE MONTHLY INTEREST
termMonRate = termRate/(12*100);
//GET TOTAL YEARS IN MONTHS
loanMonths = termYears*12;
//GET USER ENTRY FROM LOAN AMOUNT TEXTBOX
principleLoan=Double.parse
//CALCULATE LOAN PAYMENT AMOUNT UTILIZING DATA INPUT FROM USER
loanPaymentAmount = principleLoan*(termMonRate
//OUTPUT CALCULATIONT TO PAYMENT BOX
gui.tfMonPayment.setText(d
countRowNum = gui.amortizModel.getRowCou
while(countRowNum >0)
{
gui.amortizModel.removeRow
countRowNum = gui.amortizModel.getRowCou
}
for (int i=1;principleLoan>0;i++)
{
monInterest = principleLoan * termMonRate;
principle =loanPaymentAmount -monInterest;
actualPrinciple= principleLoan-principle;
totalInterest *= monInterest;
gui.amortizModel.addRow(ne
{String.valueOf(i), doCurrencyFormat.format(lo
, doCurrencyFormat.format(pr
,doCurrencyFormat.format(m
, doCurrencyFormat.format(ac
, doCurrencyFormat.format(to
principleLoan = actualPrinciple;
}
gui.clearButton.setEnabled
}
void CalcForCheckBoxSelection()
{
double principle;
double principleLoan;
double actualPrinciple;
double loanAmt=0.0;
double userMortTerm=0.0;
double loanMonths;
double userMortRate=0.0;
double termMonRate =0.0;
double monInterest =0.0;
double totalInterest=1;
double loanPaymentAmount;
int countRowNum;
//DETERMINE MONTHLY INTEREST
userMortRate = Double.parseDouble (gui.tfuserMortRate.getTex
termMonRate = userMortRate/(12*100);
//GET TOTAL YEARS IN MONTHS
userMortTerm =Double.parseDouble(gui.tf
loanMonths = userMortTerm*12;
//GET USER ENTRY FROM LOAN AMOUNT TEXTBOX
principleLoan=Double.parse
//CALCULATE LOAN PAYMENT AMOUNT UTILIZING DATA INPUT FROM USER
loanPaymentAmount = principleLoan*(termMonRate
//OUTPUT CALCULATIONT TO PAYMENT BOX
gui.tfMonPayment.setText(d
countRowNum = gui.amortizModel.getRowCou
while(countRowNum >0)
{
gui.amortizModel.removeRow
countRowNum = gui.amortizModel.getRowCou
}
for (int i=1;principleLoan>0;i++)
{
monInterest = principleLoan * termMonRate;
principle =loanPaymentAmount -monInterest;
actualPrinciple= principleLoan-principle;
totalInterest *= monInterest;
gui.amortizModel.addRow(ne
{String.valueOf(i), doCurrencyFormat.format(lo
, doCurrencyFormat.format(pr
,doCurrencyFormat.format(m
, doCurrencyFormat.format(ac
, doCurrencyFormat.format(to
principleLoan = actualPrinciple;
}
}
//CLEAR FIELD METHOD
void clearAllFields()
{
int countRowNum =0;
//CLEARING ALL FIELD
gui.tfLoanAmt.setText(null
gui.tfMonPayment.setText(n
countRowNum= gui.amortizModel.getRowCou
while(countRowNum >0)
{
gui.amortizModel.removeRow
countRowNum = gui.amortizModel.getRowCou
}
gui.clearButton.setEnabled
}
//public class ReadWriteTextFile ()
void ReadWriteTextFile ()
{
int fileData;
File inputFile = new File("C:\\Kathy.txt");
try{
FileInputStream aFile = new FileInputStream(inputFile)
while((fileData = aFile.read())>0)
System.out.print((char)fil
aFile.close();
} catch (IOException e) {
System.out.print("Could not read file");
}
}
public void itemStateChanged(ItemEvent
{
gui.userSelectBox = (JCheckBox)evt.getItemSele
if (gui.userSelectBox.isSelec
gui.cboMortTerm.setEnabled
CalcForCheckBoxSelection()
else {
gui.cboMortTerm.setEnabled
JComboBox term = (JComboBox)evt.getSource()
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The previous assumes a single-line file with values separated by spaces.
try{
FileInputStream aFile = new FileInputStream(inputFile)
} catch (IOException e) {
System.out.print("Could not read file");
}
to
FileInputStream aFile;
try{
afile = new FileInputStream(inputFile)
} catch (IOException e) {
System.out.print("Could not read file");
}
or move the while inside the try block:
try{
FileInputStream aFile = new FileInputStream(inputFile)
while((fileData = aFile.read())>0)
System.out.print((char)fil
aFile.close();
} catch (IOException e) {
System.out.print("Could not read file");
}