Error Cannot Find Symbol Symbol Method Powdouble Double
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Math.pow— cannot find symbol? up vote 0 down vote favorite I'm having troubles with my java programming class assignment for attempting to calculate the monthly mortgage amount created in the program. Once trying to compile the code, I am getting the error 'cannot find symbol - method inter(double)' The formula for calculating the monthly interest rate is - I'm currently thinking that the double value cannot be seen outside of the switch statement, but i'm not quite sure what the problem is here. ._.; Thanks for your help! my code: import java.util.*; public class MorgageCalculator { public static void main(String[]args) { Scanner s = new Scanner(System.in); double principal = 0;//principle amount int period =0;//number of years required to pay out mortgage double inter =0; //interest rate int amr =0;//monthly payments char another ='y'; double monthly=0; String input; System.out.println("Enter principle amount, value cannot be negative"); principal=s.nextDouble(); while(principal <=0){ while(inter==0){ System.out.println("Enter mortage term: (1,2,3,5,10)"); period=s.nextInt(); switch(period){ case 1: inter=3.5; break; case 2: inter=3.9; break; case 3: inter=4.4; break; case 5: inter=5.0; break; case 10: inter=6.0; break; default: inter=0; } if(inter==0){System.out.printf("%f is not a valid period, please enter a new one \n",period); } } System.out.printf("The inter rate for the term will be %.2f \n",inter); while(amr==0){ System.out.println("Enter morgage amortization period (5,10,15,20,25)"); amr=s.nextInt(); switch(amr){ case 5: amr= 5*12; break; case 10: amr= 10*12; break; case 15: amr= 15*12; break; case 20: amr= 20*12; break; case 25: amr= 25*12; break; default: amr= 0; } if(amr==0){ System.out.printf("%f is not a valid amortization period, please enter a new one."); } } inter=inter/100; monthly=(principal(Math.pow(inter(1+inter),amr))/(Math.pow(1+inter,amr)-1)); } } } java share|improve this question edited Sep 29 '14 at 23:53 Jim Lewis 26.4k451
to 7 of 7 Thread: Math.pow returning cannot find symbol LinkBack LinkBack URL About LinkBacks Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Search Thread Advanced Search Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 07-09-2011,07:05 PM #1 jmanv888 Member Join Date Jul 2011 Posts 4 Rep Power 0 Math.pow returning cannot find symbol I am very new to java and I don't http://stackoverflow.com/questions/26110617/math-pow-cannot-find-symbol know if I am not using the proper input or what. I get: cannot find symbol symbol: method pow(double,double) location: class Math I know I am doing something small wrong but I don't know what it is. Please help Thank you, Jason Java Code: import java.util.Scanner; public class Math { public static void main(String[] args) http://www.java-forums.org/new-java/46266-math-pow-returning-cannot-find-symbol.html { Scanner kbReader = new Scanner(System.in); System.out.println("Make your arithmetic selection from the choices below:\n"); System.out.println(" A. Addition"); System.out.println(" S. Subtraction"); System.out.println(" M. Multiplication"); System.out.println(" D. Division"); System.out.println(" P. Power\n"); String choice = kbReader.nextLine(); char ch = choice.charAt(0); System.out.print("\nEnter First operand."); double op1 = kbReader.nextDouble(); System.out.print("\nEnter second operand."); double op2 = kbReader.nextDouble(); System.out.println(" "); switch (ch) { case 'A': //addition case 'a': //Notice we are providing for both capital A and little a. System.out.println(op1 + " plus " + op2 + " = " + (op1 + op2)); break; case 'S': //subtraction case 's': System.out.println(op1 + "| minus " + op2 + " = " + (op1 - op2)); break; case 'M': //multiplication case 'm': System.out.println(op1 + " times " + op2 + " = " +(op1 * op2)); break; case 'D': //division case 'd': System.out.println(op1 + " divided by " + op2 + " = " + (op1 / op2)); break; case 'P': //Power case 'p': System.out.println(Math.[B]pow[/B](op1, op2)); break; default: System.out.println("H
3 Replies - 2910 Views - Last Post: 13 November 2011 - 04:09 PM Rate Topic: #1 JimmyDean New D.I.C Head Reputation: 0 Posts: 9 Joined: 12-October 11 Math.Pow problems Posted 13 November 2011 - 03:59 http://www.dreamincode.net/forums/topic/255516-mathpow-problems/ PM I am having a problem getting this to work. Have been looking at it and searching the internet for a couple hours now and I am finally ready to ask for help! What do I need to do to make this compile? I am trying to do a program for the interest rate on a car. The formula that I am trying to use is: QuoteP ( r / 12 error cannot ) ------------------------- (1 - ( 1 + r / 12 )^-m ) Here is the error: Quote---------------- JDK Debug Build ------------------ Compiling K:\untitled folder\Comp2243\Assignment7\CarLoanCalc.java The current directory is: K:\untitled folder\Comp2243\Assignment7 Command line: "C:\Program Files\Java\jdk1.6.0_23\bin\javac.exe" -deprecation -g -classpath K:\UNTITL~1\COMP2243\AS3C77~1 "K:\untitled folder\Comp2243\Assignment7\CarLoanCalc.java" K:\untitled folder\Comp2243\Assignment7\CarLoanCalc.java:101: cannot find symbol symbol : method Pow(double,int) location: class java.lang.Math bottom = (Math.Pow((1 - (1 + interestRate/12)), (term * (-12)))); ^ 1 error Finished and here is the error cannot find code: private class CalculateButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { double loanAmount, interestRate, payment, top, bottom; int exponent, term; loanAmount = Double.parseDouble(loanAmountTF.getText()); interestRate = Double.parseDouble(interestRateTF.getText()); term = Integer.parseInt(interestRateTF.getText()); //exponent = Math.Pow(term * (- 12)); top = (loanAmount * (interestRate/12)); bottom = (Math.Pow((1 - (1 + interestRate/12)), (term * (-12)))); payment = top/bottom; resultTF.setText("" + payment); } } Sorry for the messy code. I had been trying a few different things when I finally gave up (top, bottom, payment). Is This A Good Question/Topic? 0 Back to top MultiQuote Quote + Reply Replies To: Math.Pow problems #2 GregBrannon D.I.C Lover Reputation: 2250 Posts: 5,340 Joined: 10-September 10 Re: Math.Pow problems Posted 13 November 2011 - 04:00 PM You need to learn to use the API. This is a 2-second search: Java Math.pow() method. Note the small 'p'. Was This Post Helpful? 0 Back to top MultiQuote Quote + Reply #3 JimmyDean New D.I.C Head Reputation: 0 Posts: 9 Joined: 12-October 11 Re: Math.Pow problems Posted 13 November 2011 - 04:08 PM Are you kidding me..... UGH! I tried that a while ago and it didn't fix it. Must have had something else wrong at the same time (obviously). Thanks! Was This Post Helpful? 0 Back to t