DoubleM's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
10 (0.02 per day)
Joined:
26-June 12
Profile Views:
346
Last Active:
User is offline Jul 23 2012 03:27 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   DoubleM has not set their status

Posts I've Made

  1. In Topic: Password reset issues

    Posted 23 Jul 2012

    View PostDoubleM, on 23 July 2012 - 01:41 PM, said:

    Hello. Yes, it was a couple of weeks since my last visit and I forgot my password. Yes, I went through the proper channels for password reset. I received the e-mails with new 'auto-generated' passwords.
    Upon logging back in, I'm trying to reset my password using the one just received in my Inbox. However, it says that it's not correct. I have been through this at least twice now. After a few tries, I'm locked out for 15 minutes and the process starts all over.
    Any assistance in this matter is greatly appreciated.
    Thanks
    -Double M


    Ok...on a whim, I entered what the site previously said was incorrect. ....and, it worked. So,...please disregard my previous post. Thanks
    -DoubleM
  2. In Topic: formula for mortgage calc. Numerator/Denominator with no values.

    Posted 29 Jun 2012

    Good morning. I'm back.
    Still working with the same code. Now that the Num/Denom' issue is fixed and I do understand why now ... ( still haven't gotten a reply from my professor on that question.) This is another common, simple issue (for others) that plagues a lot of Java-newbies like me.

    Currently, the program recognizes only the first index of each array as valid input. It does not see termYears[15] or [30] or their paired termRates[i] at all. I was thinking that...as is, it doesn't have a way to collect for the other indexes before it jumps straight into checking those conditions with all the IF/Else statements.

    So, I put a For Loop at the top, before those conditions on line 37 so it could iterate through the idexes, checking the users input. And a new error. "i is already defined in java.lang." which I fully agree with and understand, because I declared it at line 16. I also declared a "j" at line 17, though I do not know why.
    So, to experiment, I comment i out at line 16 which produces the error "can not find variable i" ...which is used to refer to all of my instances of the termYear[i] and termRate[i]. ...

    This is where we newbies can get discouraged because the original issue was to find 15 & 30 and errors generate errors and now torn between the declaration of my variables.
    Look.. I know this is such a simple, crayon-fix for many more advanced Java-tiers ...but this is my challenge for the moment that I'm ready to understand and move beyond it. Any additional insight and guidance is appreciated.
    Please overlook the comments at the bottom. These are just additional attributes I want to later add, but you see where I want to go with its functionality.
    import static java.lang.System.out;
    import java.text.NumberFormat;
    import java.util.Scanner;
                    
    //  @author Matthew
     
    public class MayArray {
    
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            int    principleAmount = 200000;    // Variable Declaration Statements
            int    termMonths = 0;
            
    //        int    i=0;
            int    j=0;
            int    inputYears=0;
            double monthlyInterestRate = 0;
            double formulaNumerator = 0;
            double formulaDenominator = 0;
            double monthlyPayment = 0; 
            double inputRate=0;
            char   y = 0;
            
            NumberFormat currency = NumberFormat.getCurrencyInstance();
            
            int termYear [] = {7,15,30};  //Declaring  and Store Values in Array indexes. 
            double termRate [] = {5.35, 5.5, 5.75};        
    
            out.println("Hello and welcome to McBride Financials' new mortgage calculator.");
            out.println("For your principle amount of $200,000.00, enter the  loans' term of years.");//user prompt
            
            Scanner loanScanner = new Scanner (System.in);		//initialize Scanner.
            inputYears = loanScanner.nextInt ( );
            
            for (int i=0; i < 3; i++){  //For Loop for the 3 interest rates.
                                    }
            if (inputYears!= (termYear[i]))  {     //Validates user input
                out.println("Sorry, you entered an invalid option for the term of years: 7, 15 or 30. Please try again.");//Error Message to User
            } else {
                
                if (inputYears == (termYear[i])) { //
                    out.println("Next, please enter the Annual Percentage Rate of the loan. (without percentage symbols)");//user prompt
                   
                        inputRate = loanScanner.nextDouble ( );   //Accepts entered APR.
                        if (inputRate != (termRate[i]) ){   //Validates input. 
                        out.println("Sorry, you entered an invalid option for the APR . Please try again.");
    
                        } else {  
                            
                        for (int k=0; k < 3; k++){  //For Loop for the 3 interest rates.
                                    } 
                      monthlyInterestRate = termRate[i]/ 100 / 12;  //termRate==annualInterestRate
    
                        //Divide interestRate by 100 to return decimal value. termRate[i]/ 100 / 12=  
                        //Divide the results by 12 to return the monthly intest rate.        
                termMonths = termYear[i] * 12; //obtains months from 7,15 & 30 yr.terms.
    
                //Find the numerator of the formula.Multiply the monthlyInterestRate by principleAmount.
                formulaNumerator = (monthlyInterestRate * principleAmount);
                       
                //Solve for Denominator by using Javas' .pow function.
                formulaDenominator = 1 - (java.lang.Math.pow((1 + monthlyInterestRate), (-1 * termMonths)));
                monthlyPayment = formulaNumerator / formulaDenominator;
                    // Display formatted payment amount
             
                String sprincipleAmount = currency.format(principleAmount);
                String sMonthlyPayment = currency.format(monthlyPayment);
                out.println("Your mortgage principle of " + sprincipleAmount 
                    + " for " + termYear[i] +" years at " + termRate[i] + "% APR comes to " 
                    + sMonthlyPayment + " monthly. \n"); 
                        
                
                out.println("Would you like to calculate for another term loan?");
                out.println("Enter Y for 'yes' or Esc to Exit the loan calculator.");
                
                
    //            public static boolean [yes] ( [char] ['y'] );
    //            boolean yes = true;
    //            char    yes = new char('y')      
    //                    	      finalAnswer=answer.compareTo(finalName);
    //      if(finalAnswer!=0)
    //      {
    //            yes=false;
    //      }
    //      return yes;      
    // }
    //            .compareTo();  
    //            if..
    //            boolean input.nextChar == 'y';
    //            while (what are my conditions? ) 
            // outputs the payment for three loans 
            // loan terms and rates are in array variables
    //            for (int i=0; i<=2; i++){        
    //      
    //            monthlyInterestRate = termRate/ 100 / 12;
    //            termMonths = termYear * 12;
    //
    //            // calculate the payment (calculate the numerator and denominator first)
    //            formulaNumerator = (monthlyInterestRate * principleAmount);
    //            formulaDenominator = 1 - (java.lang.Math.pow((1 + monthlyInterestRate), (-1 * termMonths)));
    //
    //            monthlyPayment = formulaNumerator / formulaDenominator;
    //
    //            // Display formatted payment amount
    //            sPrincipleAmount = currency.format(principleAmount);
    //            sMonthlyPayment = currency.format(monthlyPayment);
    //            out.println("Your mortgage principle of " + sPrincipleAmount 
    //                + " for " + termYear +" years at " + termRate + "% APR comes to " 
    //                + sMonthlyPayment + " monthly. \n");     
    //         
    //        } // end for loop
         
                               
               } //End Else #2
            }  // Close If #2
        }   //Close Else #1
      }   //Close Main
    }//Close Class
    
    
    
  3. In Topic: formula for mortgage calc. Numerator/Denominator with no values.

    Posted 28 Jun 2012

    Alright. Progress. I got it, but I need an expert explanation of ..why my changes worked. In the code posted earlier, String variables: sprincipleAmount & smonthlyPayment are declared in lines 26 and 27. I noticed in the other working version, that these variables were declared on lines 68 and 69. This fixed the errors and gave values back to the Numerator/Denominator and now calculates just fine.
    What does declaring these inside the calculation statements mean? I'm vaguely familiar with static and non-static variables. Is this what happened?...Is my train of thought on the right track?

    Thanks!
    -Matt
  4. In Topic: formula for mortgage calc. Numerator/Denominator with no values.

    Posted 28 Jun 2012

    I'm just now getting the opportunity to get back to work on this. Ok,... I didn't post all of my code the first time, because I assumed for the site rule of "no homework"...that a little ...and not all of it would be ok. That was my reasoning for that. To the point, I've cleaned up the code a little. Here it is again ...all of it. In regards of useful comments, I admit, I'm super-green and it was to help me keep my head around the structure of the program. I can handle the critique. It's cool.

    Thanks Again
    -DoubleM

    
    import static java.lang.System.out;
    import java.text.NumberFormat;
    import java.util.Scanner;
                    
    //  @author Matthew
     
    public class MayArray {
    
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            int    principleAmount = 200000;    // Variable Declaration Statements
            int    termMonths = 0;
            
            int    i=0;
            int    j=0;
            int    inputYears=0;
            double monthlyInterestRate = 0;
            double formulaNumerator = 0;
            double formulaDenominator = 0;
            double monthlyPayment = 0; 
            double inputRate=0;
            
            NumberFormat currency = NumberFormat.getCurrencyInstance();
            String sprincipleAmount = currency.format(principleAmount);
            String smonthlyPayment = currency.format(monthlyPayment);   //formatted Variables.
            
            int termYear [] = {7,15,30};  //Declaring  and Store Values in Array indexes. 
            double termRate [] = {5.35, 5.5, 5.75};        
    
            
            out.println("For your principle amount of $200,000.00, enter the  loans' term of years.");//user prompt
            
            Scanner loanScanner = new Scanner (System.in);		//initialize Scanner.
            inputYears = loanScanner.nextInt ( );
            
          
            if (inputYears!= (termYear[i]))  {     //Validates user input
                out.println("Sorry, you entered an invalid option for the term of years: 7, 15 or 30. Please try again.");//Error Message to User
            } else {
                
                if (inputYears == (termYear[i])) { //
                    out.println("Next, please enter the Annual Percentage Rate of the loan. (without percentage symbols)");//user prompt
                   
                        inputRate = loanScanner.nextDouble ( );   //Accepts entered APR.
                        if (inputRate != (termRate[i]) ){   //Validates input. 
                        out.println("Sorry, you entered an invalid option for the APR . Please try again.");
    
                        } else {    
                    
                        monthlyInterestRate = termRate[i]/ 100 / 12; 
                            out.println("monthly interest rate is " + monthlyInterestRate); //display tests values.
                             
                        termMonths = termYear[i] * 12; 
                        //Determines the numerator of the formula.
                        
                        out.println("term months equals" + termMonths);  //tests output of termMonths value. It works.
                        
                        formulaNumerator = (monthlyInterestRate * principleAmount);
                        //Solve for Denominator by using Javas' .pow function.
                        out.println (" the numerator is " + formulaNumerator); //tests vaue. it works.
                        
                        formulaDenominator = 1 - (java.lang.Math.pow((1 + monthlyInterestRate), (-1 * termMonths)));
                        out.println("the denominator is" + formulaDenominator); //tests value. works.
    
                        monthlyPayment = formulaNumerator / formulaDenominator;
                            // Display formatted payment amount
          
                        out.println("Your mortgage principle of " + sprincipleAmount 
                        + " for " + termYear[i] +" years at " + termRate[i] + "% APR comes to " 
                        + smonthlyPayment + " monthly. \n");  
                        
                                 for (int k=0; k < 3; k++){  //For Loop for the 3 interest rates.
                                    } 
               } //End Else #2
            }  // Close If #2
        }   //Close Else #1
      }   //Close Main
    }//Close Class
    
        
    
        
          
        
        
     
    
    
    
    
    
    
    
  5. In Topic: formula for mortgage calc. Numerator/Denominator with no values.

    Posted 28 Jun 2012

    View Postpbl, on 28 June 2012 - 03:50 AM, said:

    Too much is like not enough
    Group your comments together and put a few lines of code together
    And use usefull comments

     for (int k=0; k < 3; k++){  //Begin For Loop 
    
    


    do you seriously think that // Begin for loop is a useful comment ?
    // loop for the 3 interest rates would be though

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me

Friends

DoubleM hasn't added any friends yet.

Comments

DoubleM has no profile comments yet. Why not say hello?