This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Java in General and the fly likes Executable-Java! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Executable-Java!" Watch "Executable-Java!" New topic
Author

Executable-Java!

C.R.Muthukumar
Ranch Hand

Joined: Dec 03, 2004
Posts: 59
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

Joined: Sep 18, 2000
Posts: 562
    
    7

Please post the source code and the exact message you are encountering.
C.R.Muthukumar
Ranch Hand

Joined: Dec 03, 2004
Posts: 59
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

Joined: Dec 03, 2004
Posts: 59
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

Joined: Dec 03, 2004
Posts: 59
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


 
GeeCON Prague 2014
 
subject: Executable-Java!