CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    Apr 2011
    Posts
    4

    Mortgage Calculator help

    I'm closing my 6th week of Java programming and I feel like I'm riding on a roller coaster. Some parts come real easy and make sense, others I struggle mightily with. I've got an assignment that was due a few days ago and I'm struggling with it, to get it to function the way I need it to. I've managed to get the internal errors, cannot find symbols and all that jazz to all but disappear, but I'm at a loss on how to move on to the next step. Below is the code I have (main class and storage class). I get

    "Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - cannot find symbol
    symbol: constructor MortgageStorage(java.lang.String,java.lang.String,double,double)
    location: class it215mortgagecalculator2point1.MortgageStorage
    at it215mortgagecalculator2point1.it215mortgagecalculator2point1.main(it215mortgagecalculator2point1.java:80)
    Java Result: 1"

    upon completion of the last iteration of the array.

    On line 80 I have a flag showing in Netbeans that prompts me to create a constructor in the storage class. If I let Netbeans create the constructor the error above still shows up. The constructor that Netbeans puts in to the storage class is
    Code:
     MortgageStorage(String firstname, String lastname, double lAmount, double iRate) {
            throw new UnsupportedOperationException("Not yet implemented");
        }
    Any help in pointing me on how to resolve things would be greatly appreciated!! Here's the code for the main class

    Code:
     package it215mortgagecalculator2point1;
    
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    import java.util.Scanner;
    
    package it215mortgagecalculator2point1;
    
    /**
     *
     * @author Ben
     */
    public class it215mortgagecalculator2point1 {
        private static double termInyears;
        private static int s;
    
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args)
        {
            Scanner input = new Scanner(System.in);
            String firstname = null;
            String lastname = null;
            double lAmount = 0;
            double iRate = 0;
            int termInYears = 0;
    
            MortgageStorage[] ms = new MortgageStorage[2];
    
            for (double s = 0; s<ms.length; s++)
    {
    
                System.out.println("Please enter your first name: ");
                firstname = input.next();
                while (firstname.equals(" "))
    
    {
    System.out.println("You must enter a first name");
    firstname = input.next();
    
                            }
    System.out.println("Please enter your last name:");
    lastname = input.next();
    while (lastname.equals(" "))
    
    {
    System.out.println("You must enter a last name:");
    lastname = input.next();
    
    }
    System.out.println("Please enter the loan amount: $");
    lAmount=input.nextDouble();
    while(lAmount<1)
    
    {
    System.out.println("You must enter a positive value for the amount of the loan.");
    lAmount=input.nextDouble();
    
    }
    System.out.println("Please enter the interest rate of the loan (eg.5.0)");
    iRate=input.nextDouble();
    while(iRate<1)
    
    {
    System.out.println("You must enter a positive value for the interest rate");
    iRate=input.nextDouble();
    
    }
           System.out.println("Please enter the term of the loan in years");
                termInYears=input.nextInt();
    while(termInYears<1)
    {
            System.out.println("You must enter the number of years of the loan");
                termInYears=input.nextInt();
                            }
            }
                ms[s]=new MortgageStorage(firstname, lastname, lAmount, iRate);
    
    
            System.out.printf("Name: " + ms[s].getfName());
            System.out.println("Name: "+ ms[s].getlName());
            
            System.out.println();
        }
    }
    
    Code:
    and the storage class
    package it215mortgagecalculator2point1; /* * * * @author Benjamin Paulson */ class MortgageStorage { private String fName; //declare variable private String lName; private double lAmount; private double iRate; private double tIY; private double mPayment; //Constructor public MortgageStorage(String firstname, String lastname, double lAmount, double iRate, double mPayment, double tIY) { this.fName = firstname; this.lName = lastname; this.lAmount = lAmount; this.iRate = iRate; this.mPayment = mPayment; this.tIY = tIY; } MortgageStorage(String firstname, String lastname, double lAmount, double iRate) { throw new UnsupportedOperationException("Not yet implemented"); } /** * @return the fName */ public String getfName() { return fName; } /** * @param fName the fName to set */ public void setfName(String fName) { this.fName = fName; } /** * @return the lName */ public String getlName() { return lName; } /** * @param lName the lName to set */ public void setlName(String lName) { this.lName = lName; } /** * @return the lAmount */ public double getlAmount() { return lAmount; } /** * @param gOne the lAmount to set */ public void setlAmount(double lAmount) { this.lAmount = lAmount; } /** * @return the iRate */ public double getiRate() { return iRate; } /** * @param iRate the iRate to set */ public void setiRate(double iRate) { this.iRate = iRate; } /** * @return the monthlyPayment */ public double getmPayment() { // // mPayment = (lAmount * iRate + lAmount)/12; return (lAmount * iRate)/12; } }
    Last edited by SplinteredChaos; April 24th, 2011 at 05:45 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured