class Test{
int u;
int t;
int a;
void set(int velocity, int time, int acceleration){
u=velocity;
t=time;
a=acceleration;
}
double displacement(){
double s=(u*t+(1/2)*a*t*t);
return s;
}
}
class Main{
public static void main(String args[]){
Test obj=new Test();
int u=5;
int t=3;
int a=2;
obj.set(u,t, a);
double d=obj.displacement();
System.out.println("Displacement is "+d);
}
}
0 Comments