Please help me with this Java programming
Hello everyone I am a BSC Mathematics student and very beginner in Java Programming and as part of my Mathematics degree I am also learning Algorithm with Java programming. I am in very early stages of Java so I could be making very silly mistake but believe it or not but I am stuck with this error for last 2 days but still cannot figure out where is the problem. Anyone please help me I will really appreciate that.
Following is the programme code I am using:
Code :
class diy70
{
public static void main(String[] args)
{
int degree;
degree = 0;
double px, x;
/* px is the variable used to store the result of the polynomial at x.
*/
Calculate Taylor_Polynomials tp=newCalculate_Taylor_Polynomials();
// Evaluate the polynomial at x = 0.2.
x = 0.2;
switch (degree) {
case 0: px = tp.p0(x); tp.printpx(0.8, x, px); break;
case 1: px = tp.p1(x); tp.printpx(0.8, x, px); break;
case 2: px = tp.p2(x); tp.printpx(0.8, x, px); break;
default: System.out.println("nothing is done.");
}
}
static class Calculate_Taylor_Polynomials
{
/* Return the result of the polynomial in P.3 Lecture 2 */
double p0(double x)
{
double pofx =1.0;
return pofx;
}
Double p1 (double x)
{
double pofx = 1.0 + x;
return pofx;
}
double p2(double x)
{
double px = 1.0 + x + Math.pow(x,2);
return px;
}
void printpx(int degree, double x, double px)
{
System.out.println("Degree " + degree + "polynomial");
System.out.println ("P( = " + x + ")=" + px);
}
}
}
But when I run the above programme I am getting error on line 11 saying something like this:
';' expected and also there is ^ this sign between Polynomials and tp
Will wait for reply and may God bless you for this.
Re: Please help me with this Java programming
Code :
Calculate Taylor_Polynomials tp=newCalculate_Taylor_Polynomials();
It looks like you're missing a space between "new" and "Calculate_Taylor_Polynomials();"
Code :
Calculate Taylor_Polynomials tp=new Calculate_Taylor_Polynomials(); // fixed
Re: Please help me with this Java programming
Also an underscore
Code :
Calculate Taylor_Polynomials tp=newCalculate_Taylor_Polynomials();
Code :
Calculate_Taylor_Polynomials tp=new Calculate_Taylor_Polynomials();
Re: Please help me with this Java programming
Thanks , I tried this but the problems is still there . Giving me the same error
Re: Please help me with this Java programming
Thanks Chris u were right i forgot to put underscore.
Re: Please help me with this Java programming
Also Thanks for your help HelloWorld 922 . I have some more problems so i will put on this tread.