Tuesday, 16 January 2018

Core Java Practice Program

John Needs To Write A Program To Calculate The Total Distance Travelled By A Vehicle. To Calculate The Distance, John  Can Use The Following Formula:- 

                     Distance = ut + (at2)/2

Here, u is the initial velocity (meters per second),  a is the acceleration(meter per second2), and t is the time(seconds). Help John to perform desired task.


Answer:-


public class Distance {

public static void main(String[] args) {
int u , a , t , distance;
u = 23;
a= 7;
t= 12;
distance = u * t + (a * t * t )/2;
System.out.println("-----------------------------------");
System.out.println("Distance Travelled ="+distance + "meter");
System.out.println("-----------------------------------");
}

}

       

No comments:

Post a Comment

Error While embed the video in Your website page

Error:- Refused to display '<URL>' in a frame because it set 'X-Frame-Options' to 'sameorigin Solution:- if ...