Results 1 to 2 of 2
Thread: compile error
- 10-31-2011, 07:22 PM #1
Member
- Join Date
- Sep 2011
- Posts
- 6
- Rep Power
- 0
compile error
Hi can someone help me with this error ...
C:\Users\yomara.cordero\AppData\Local\Temp\7zOB19B .tmp\MortgagePaymentCalculator.java:338: error: cannot find symbol
new Chart((int)(loanTerm/12));
^
symbol: class Chart
location: class MortgagePaymentCalculator
Note: C:\Users\yomara.cordero\AppData\Local\Temp\7zOB19B .tmp\MortgagePaymentCalculator.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Tool completed with exit code 1
This is the code i used below: Please help with a solution thanks
Java Code:import java.awt.BorderLayout; // Code to Import and Provide Layout of Window import java.awt.GridLayout; // Code to Import the Layout in Grid Format import java.awt.event.ActionEvent; // Code to Import Action import java.awt.event.ActionListener; // Code to Import Listener for Action import javax.swing.JButton; // Code to Import Use of Buttons import javax.swing.JFrame; // Code to Import Use of Frame import javax.swing.JLabel; // Code to Import Use of Label import javax.swing.JPanel; // Code to Import Use of Panel import javax.swing.JTextField; // Code to Import Use of Text Field import javax.swing.JTextArea; // Code to Import Use of Text Area import javax.swing.JScrollPane; // Code to Import Scroll Pane import javax.swing.JComboBox; // Code to Import JCombo Box import java.text.DecimalFormat; // Code to Import Decimal Format to Eliminate Extra Places Past Decimal Point import javax.swing.JRadioButton; import javax.swing.ButtonGroup; import javax.swing.JOptionPane; import java.awt.Dimension; import java.io.*; import java.util.StringTokenizer; // Create Mortgage Payment Class public class MortgagePaymentCalculator extends JFrame { DecimalFormat Dollar = new DecimalFormat("$###,###.00"); // Declare Variables and Values private double loanAmount; // Amount of Loan private double loanTerm; // Term of Loan private double loanRate; // Interest Rate of Loan private double monthlyRate; // Amount of Monthly Interest private double monthlyPayment; // Amount of Monthly Payment private double monthlyInterest; // Amount of Monthly Interest Rate private double monthlyamountInterest; // Amount of Monthly Interest private double monthlyPrinciple; // Amount of Monthly Principle private double loanBalance; // Balance of Loan private double newBalance; // New Monthly Balance of Loan private double newMonthlyBalance; private double newMonthlyPayment; private double newLoanTerm; private double newBalInt; // New Term of Loan private static int numberOfLinesGenerated=1; // GUI elements to Display Current Information private JLabel principalLabel = new JLabel(" Mortgage Principal : "); private JTextField principalText = new JTextField(10); private JLabel yearsLabel = new JLabel(" Mortgage Time In Years : "); private JTextField yearsText = new JTextField(10); private JLabel rateLabel = new JLabel(" Amount Interest Rate : "); private JTextField rateText = new JTextField(10); private JRadioButton rbutton1 = new JRadioButton(); private JRadioButton rbutton2 = new JRadioButton(); private ButtonGroup buttongroup = new ButtonGroup(); private JTextArea result = new JTextArea(10, 20); JScrollPane scrollingResult = new JScrollPane(result); private JButton btnCalculate = new JButton("Calculate"); private JButton btnReset = new JButton("Reset"); private JButton btnNext = new JButton("Next"); private JButton btnExit = new JButton("Exit"); private JButton btnChart = new JButton("Chart"); private JPanel centerPanel = new JPanel(); private JPanel buttonPanel = new JPanel(); private JPanel nextButtonPanel = new JPanel(); JPanel p=new JPanel(new BorderLayout()); String scheme[] = {"Select Scheme","7 years at 5.35%","10 years at 5.0%","15 years at 5.5%","30 years at 5.75%"}; private JLabel schemeLabel = new JLabel(" Mortgage Scheme : "); private JComboBox combo = new JComboBox(scheme); // Create Container for Information public MortgagePaymentCalculator() { btnCalculate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { onButtonCalculate(); } }); btnReset.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { onButtonReset(); } }); btnNext.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { onButtonNext(); } }); btnExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); btnChart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { onButtonChart(); } }); centerPanel.setLayout(new GridLayout(5, 2,3,3)); centerPanel.add(principalLabel); centerPanel.add(principalText); rbutton1.setText("Get Values From File OR "); rbutton2.setText("Choose Values "); buttongroup.add(rbutton1); rbutton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { rbutton1ActionPerformed(evt); } }); rbutton1.setSelected(true); buttongroup.add(rbutton2); rbutton2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { rbutton2ActionPerformed(evt); } }); centerPanel.add(rbutton1); centerPanel.add(rbutton2); centerPanel.add(yearsLabel); centerPanel.add(yearsText); centerPanel.add(rateLabel); centerPanel.add(rateText); centerPanel.add(btnCalculate); centerPanel.add(btnReset); nextButtonPanel.add(btnChart); nextButtonPanel.add(btnNext); nextButtonPanel.add(btnExit); final Dimension dim = new Dimension(200, 200); setLayout(new BorderLayout()); add(centerPanel, BorderLayout.NORTH); p.add(nextButtonPanel, BorderLayout.NORTH); p.add(scrollingResult, BorderLayout.SOUTH); btnExit.setEnabled(false); btnNext.setEnabled(false); btnChart.setEnabled(false); add(p, BorderLayout.SOUTH); pack(); setDefaultCloseOperation(EXIT_ON_CLOSE ); setResizable(false); setTitle("Mortgage Calculator"); setVisible(true); } private void rbutton1ActionPerformed(ActionEvent evt) { if(rbutton1.isSelected()){ centerPanel.removeAll(); centerPanel.add(principalLabel); centerPanel.add(principalText); centerPanel.add(rbutton1); centerPanel.add(rbutton2); centerPanel.add(yearsLabel); centerPanel.add(yearsText); centerPanel.add(rateLabel); centerPanel.add(rateText); centerPanel.add(btnCalculate); centerPanel.add(btnReset); setVisible(true); } } private void rbutton2ActionPerformed(ActionEvent evt) { if(rbutton2.isSelected()){ centerPanel.removeAll(); centerPanel.add(principalLabel); centerPanel.add(principalText); centerPanel.add(rbutton1); centerPanel.add(rbutton2); centerPanel.add(schemeLabel); centerPanel.add(combo); centerPanel.add(btnCalculate); centerPanel.add(btnReset); setVisible(true); } } // Calculate Information public void onButtonCalculate() { double loanAmt=Double.parseDouble(principalText.getText() ); AssignloanAmount(loanAmt); // Assign Amount of Loan if(rbutton1.isSelected()) { try { StreamTokenizer st=new StreamTokenizer(new BufferedReader(new FileReader("loandata.txt"))); int linecount=0; while(st.nextToken()!=StreamTokenizer.TT_EOF) { if(st.lineno() ==numberOfLinesGenerated) { if(st.ttype==StreamTokenizer.TT_NUMBER) AssignloanTerm(st.nval*12); yearsText.setText(""+st.nval); st.nextToken(); if(st.ttype==StreamTokenizer.TT_NUMBER) AssignloanRate(st.nval); rateText.setText(""+st.nval); break; } System.out.println (st.lineno()) ; } }catch (Exception addException){//Catch exception if any JOptionPane.showMessageDialog(null, "Error While reading Loandata file\n" + addException); } } else { String str = (String)combo.getSelectedItem(); if(str.equals("7 years at 5.35%")) { AssignloanRate(5.35); AssignloanTerm(7*12); } else if(str.equals("10 years at 5.0%")) { AssignloanRate(5.0); AssignloanTerm(10*12); } else if(str.equals("15 years at 5.5%")) { AssignloanRate(5.5); AssignloanTerm(15*12); } else if(str.equals("30 years at 5.75%")) { AssignloanRate(5.75); AssignloanTerm(30*12); } } CalculatemonthlyPayment(); // Calculate Monthly Payment of Loan CalculatemonthlyInterest(); // Calculate Monthly Interest on Loan CalculatemonthlyPrinciple(); // Calculate Monthly Principle of Payment CalculateloanBalance(); // Calculate Loan Balance CalculatenewBalance(); // Calculate New Balance Each Month DisplayAmounts(); // Display All Amounts MonthlyloanAmount(); MonthlybalanceInterest(getAssignloanAmount(), getAssignloanTerm(), getAssignloanRate()); ++numberOfLinesGenerated; if(numberOfLinesGenerated>4) numberOfLinesGenerated=1; btnCalculate.setEnabled(false); btnReset.setEnabled(false); btnExit.setEnabled(true); btnNext.setEnabled(true); btnChart.setEnabled(true); } // Information for Button public void onButtonReset() { principalText.setText(""); yearsText.setText(""); rateText.setText(""); result.setText(""); } public void onButtonNext() { btnCalculate.setEnabled(true); btnReset.setEnabled(true); btnExit.setEnabled(false); btnNext.setEnabled(false); btnChart.setEnabled(false); } public void onButtonChart() { new Chart((int)(loanTerm/12)); System.out.println(""+loanTerm); } // Display Methods to Print Values for Morgage Calculator public void AssignloanAmount(double loanAmountFromMain) { loanAmount = loanAmountFromMain; } public void AssignloanRate(double interestAmountFromMain) { loanRate = interestAmountFromMain; } public void AssignloanTerm(double termAmountFromMain) { loanTerm = termAmountFromMain; } public double getAssignloanAmount() { return loanAmount; } public double getAssignloanRate() { return loanRate ; } public double getAssignloanTerm() { return loanTerm; } public void CalculatemonthlyPayment() { monthlyRate = (loanRate / 100) / 12; monthlyPayment = loanAmount*((monthlyRate*(Math.pow((1 + monthlyRate),loanTerm)))/(Math.pow((1 + monthlyRate),loanTerm)-1)); } public void CalculatemonthlyInterest() { monthlyInterest = (loanRate / 12) / 100; monthlyamountInterest = loanAmount * monthlyInterest; } public void CalculatemonthlyPrinciple() { monthlyPrinciple = monthlyPayment - monthlyamountInterest; } public void CalculateloanBalance() { loanBalance = loanAmount - monthlyPrinciple; } public void CalculatenewBalance() { newBalance = loanBalance - monthlyPrinciple; } public void MonthlyloanAmount() { result.append("Month\tLoanBalance\tInterest Paid\n"); double newloanTerm = loanTerm; while (newloanTerm>0) { double loanMonths = loanTerm-newloanTerm; double newMonthlyBalance = loanAmount*((Math.pow((1 + monthlyInterest),loanTerm))-(Math.pow((1 + monthlyInterest),loanMonths)))/(Math.pow((1 + monthlyInterest),loanTerm)-1); double monthlyamountInterest = newMonthlyBalance * monthlyInterest; result.append(""+Math.round(newloanTerm) + "\t" + Dollar.format(newMonthlyBalance) + "\t" + Dollar.format(monthlyamountInterest) + "\n"); newloanTerm = newloanTerm - 1; } } public void MonthlybalanceInterest(double loan, double term, double interestRate) { DecimalFormat df = new DecimalFormat("$###,###.00"); // Format Decimal Point double monthlyRate = (interestRate/(12*100)); // Get Monthly Interest Rate // Calculate Discount Factor double discountFactor = (Math.pow((1 + monthlyRate), term) -1) / (monthlyRate * Math.pow((1 + monthlyRate), term)); double payment1 = loan / discountFactor; // Calculate Monthly Payment // Display Program Results result.append("\nLoan Amount = " + df.format(loan)); result.append("\nInterest Rate = " + interestRate + "%"); result.append("\nLength of Loan = " + Math.round(term/12) +" years"); result.append("\nMonthly Payment = " + df.format(payment1) + "\n"); } public void DisplayAmounts() { System.out.println("Loan Amount = " + Dollar.format(loanAmount)); // Show Original Loan Amount System.out.println("Interest Rate = " + loanRate +"%"); // Show Interest Rate System.out.println("Length of Loan = " + Math.round(loanTerm) + " months"); // Show Length of Loan System.out.println("Monthly Payment = " + Dollar.format(monthlyPayment)); // Show Monthly Payment } public static void waitScroll() { try { Thread.sleep(50); } catch (InterruptedException e) { e.printStackTrace(); } } // Beginning of Main public static void main(String[] args) { MortgagePaymentCalculator newloan = new MortgagePaymentCalculator(); // Create Instance of Class } }Last edited by JosAH; 10-31-2011 at 07:44 PM. Reason: added [code] ... [/code] tags
- 10-31-2011, 07:48 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,424
- Blog Entries
- 7
- Rep Power
- 17
Re: compile error
When people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
Compile Error
By gcorreageek in forum Advanced JavaReplies: 2Last Post: 09-08-2010, 05:23 AM -
Compile error - unchecked
By pahiker in forum New To JavaReplies: 18Last Post: 06-24-2010, 09:27 AM -
compile error
By angryredantz in forum New To JavaReplies: 1Last Post: 01-23-2009, 10:44 PM -
Compile Error - Please Help!!
By AJ2009 in forum New To JavaReplies: 10Last Post: 01-04-2009, 03:59 PM -
compile error
By dirtycash in forum New To JavaReplies: 6Last Post: 12-12-2007, 06:00 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks