This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Executable-Java!

 
C.R.Muthukumar
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Java Friends
Can any of you please point out what is the most important error/reason causing the program tiedup with this error message :nosuchmethods ,though it is an errorless one on compilation.(
1)The classfile is created.
2)the objects are there.
3)main method is available(with static/without static tried)
But still it is not executing.
Shall I forward the code on hearing from you
Best Wishes for a solution.
Thanks
As Always
C.R.Muthukumar
 
Steve Fahlbusch
Bartender
Posts: 605
7
Mac OS X Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post the source code and the exact message you are encountering.
 
C.R.Muthukumar
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Steve Fahlbusch:
Please post the source code and the exact message you are encountering.


Hello
Please try to treat the program emphasising more on object orientation consisting of a large number of functions.Subsequent to recent compilation the result of the same is indicated as only Solution without the output.
The details are as under

1)function(f(x,y)
2)xo,yo
3)increment h
4)number of y values to be found.n
Using Euler's method the following values will be computed
x1,x2,x3 ...xn,y1,y2,y3...yn
The algorithm is:
1)for i=0 to n-1
2)xi+1=xi+h
3)yi+1=yi+hf(x,y)
4)print xi+1,yi+1
5)next i
6)end

The code:
import java.text.*;
import java.util.*;
import java.lang.Math;
import java.lang.Number;
import javax.swing.*;
import java.awt.event.*;
public class EulerIVP1 extends JFrame implements ActionListener{
int n;
double h;
double x[],y[],f[];
public void EulerIVP1(int n,double ax,double ay,double h)
{

setTitle("Euler");
setLayout(new FlowLayout());
addWindowListener(new WH());

this.n=n;
x = new double[n];
y = new double[n];
f = new double[n];
x[0]= ax;

for (int i=1; i<n+1; i++)
x[i] = x[0] + (double)i * h;
y[0] = ay;
}


public double findf(double x, double y)
{
double f = x*x + y*y;
return f;
}

class WH extends WindowAdapter{

public void windowClosing(WindowEvent e)
{
System.exit(0);
}

}



public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand().equals(displaySolution()));

JFrame frame= new JFrame();


EulerIVP1 eqn;
eqn=new EulerIVP1();

eqn.setBounds(1,1,200,300);
eqn.findSolution();
eqn.displaySolution();
eqn.setVisible(true);
eqn.show();


}

public double findSolution()
{

for(int i=1;i < n+1;i++)
{
f[i] = findf(x[i],y[i]);
y[i+i] = y[i] + h * f[i];
}
return;
}
public double displaySolution()
{
System.out.println("Solution");
for (int i=1;i<n+1;i++)
{

System.out.println("x:"+ x[i] + "y:" +y[i]);

}
return;
}

public static double main(String[] args){

double ax;
double ay;
int n=0;
double h=0.5;
EulerIVP1 eqn=new EulerIVP1();
JFrame frame= new JFrame();

eqn.setBounds(1,1,200,300);
eqn.findSolution();
eqn.displaySolution();
eqn.setVisible(true);
eqn.show();

}
}
Hope to get the solutions with the output for this numerical computations
Thanking You
As Always
C.R.Muthukumar
 
C.R.Muthukumar
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by C.R.Muthukumar Muthukumar:


Hello
Please try to treat the program emphasising more on object orientation consisting of a large number of functions.Subsequent to recent compilation the result of the same is indicated as only Solution without the output.
The details are as under

1)function(f(x,y)
2)xo,yo
3)increment h
4)number of y values to be found.n
Using Euler's method the following values will be computed
x1,x2,x3 ...xn,y1,y2,y3...yn
The algorithm is:
1)for i=0 to n-1
2)xi+1=xi+h
3)yi+1=yi+hf(x,y)
4)print xi+1,yi+1
5)next i
6)end

The code:
import java.text.*;
import java.util.*;
import java.lang.Math;
import java.lang.Number;
import javax.swing.*;
import java.awt.event.*;
public class EulerIVP1 extends JFrame implements ActionListener{
int n;
double h;
double x[],y[],f[];
public void EulerIVP1(int n,double ax,double ay,double h)
{

setTitle("Euler");
setLayout(new FlowLayout());
addWindowListener(new WH());

this.n=n;
x = new double[n];
y = new double[n];
f = new double[n];
x[0]= ax;

for (int i=1; i<n+1; i++)
x[i] = x[0] + (double)i * h;
y[0] = ay;
}


public double findf(double x, double y)
{
double f = x*x + y*y;
return f;
}

class WH extends WindowAdapter{

public void windowClosing(WindowEvent e)
{
System.exit(0);
}

}



public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand().equals(displaySolution()));

JFrame frame= new JFrame();


EulerIVP1 eqn;
eqn=new EulerIVP1();

eqn.setBounds(1,1,200,300);
eqn.findSolution();
eqn.displaySolution();
eqn.setVisible(true);
eqn.show();


}

public double findSolution()
{

for(int i=1;i < n+1;i++)
{
f[i] = findf(x[i],y[i]);
y[i+i] = y[i] + h * f[i];
}
return;
}
public double displaySolution()
{
System.out.println("Solution");
for (int i=1;i<n+1;i++)
{

System.out.println("x:"+ x[i] + "y:" +y[i]);

}
return;
}

public static double main(String[] args){

double ax;
double ay;
int n=0;
double h=0.5;
EulerIVP1 eqn=new EulerIVP1();
JFrame frame= new JFrame();

eqn.setBounds(1,1,200,300);
eqn.findSolution();
eqn.displaySolution();
eqn.setVisible(true);
eqn.show();

}
}
Hope to get the solutions with the output for this numerical computations
Thanking You
As Always
C.R.Muthukumar


The same Java Code now given under concrete datas and with slight modification is being brought forward to indicate that success always follow
when the job is done in a plethora of times .
Thanks
As Always
C.R.Muthukumar



 
C.R.Muthukumar
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by C.R.Muthukumar Muthukumar:


The same Java Code now given under concrete datas and with slight modification is being brought forward to indicate that success always follow
when the job is done in a plethora of times .
Thanks
As Always
C.R.Muthukumar





Hello RanchHands,
I was able to code the above Euler'sIVP program successfully rendering output. Howevevr,a similar program,coded for obtaining the MagicSquare,though,fully clears in compilation, the output is not forthcoming.Can any of ranchhands or their superiors help out for worthwhile modification.
Thanks
As Always
C.R.Muthukumar


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic