import java.util.Scanner;
import java.lang.Math;
public class Assignment1{
//instance variables
double a;
double b;
double c;
// method
public double hypot(double x, double y){
x = x*x;
y = y*y;
double z = x+y;
z = Math.sqrt(z);
return z;
}
// constructor
public Assignment1(double a , double b, double c){
this.a = a;
this.b = b;
this.c = c;
}
public static void main(String [] args){ // execution starts from here
Assignment1 obj = new Assignment1(a,b,c);
Scanner in = new Scanner(System.in);
System.out.println("Enter the values to compute the pythagoras theorem");
obj.a = in.nextDouble();
obj.b = in.nextDouble();
obj.c = hypot(a,b);
System.out.println("The hypot is"+ c);
}
}
What is the problem with this code... I m creating the objects... then it should worl fine !! Aint it???