Need help on passing values from one method to another
R .sourav nayak
Ranch Hand
Joined: May 14, 2006
Posts: 67
posted
0
hi, i have twomethod in a java class named polynomail.I wanted to pass the value generated in constructPolynomial()method to displaySelf()method. How do i do that.Below is the prigram i have written so far.. and even i wanted to findout the value of ax^2+ bx + c in a method named functionvalue().Thank you very much in adavnce
private double quadratic_co; private double linear_co; private double constant; public Polynomial(){ } public void constructPolynomial(){ Scanner scan = new Scanner(System.in); System.out.println("Enter the coefficient of the quadratic term:"); quadratic_co = scan.nextDouble(); System.out.println(); System.out.println("Enter the coefficient of the linear term:"); linear_co = scan.nextDouble(); System.out.println(); System.out.println("Enter the coefficient of the constant term:"); constant = scan.nextDouble(); } /*public double functionValue(double x,double value, double constant){
value =( (x*x)*quadratic_co) + (x* linear_co)+ constant; return value;
}*/
public void displaySelf(double quadratic_co, double linear_co, double constant ){
} public class Assi3 { public static void main(String args[]) { Polynomial p = new Polynomial(); p.constructPolynomial(); //p.functionValue(4.0); p.displaySelf(); } }
sven studde
Ranch Hand
Joined: Sep 26, 2006
Posts: 148
posted
0
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: Need help on passing values from one method to another