Design a program using class in v2=u2+2gs in Java program

 Design a program using class in v2=u2+2gs in Java program 


class Test{
    int u;
    int h;

    void set(int vel, int height){
        u=vel;
        h=height;
    }

    double velocity(){
        double v=Math.sqrt(u*u+2*9.8*h);
        return v;
    }
    
}

class Main{
    public static void main(String args[]){
        Test obj=new Test();
        int u=5;
        int h=3;
       
        obj.set(u,h);
        double v=obj.velocity();
        
        System.out.println("The Velocity is "+v);
    }
}

Post a Comment

0 Comments