Computer Science, asked by aditipup, 7 months ago

The distance travelled by a vehicle in t seconds is given as Distance=ut+1/2at2 where u is initial velocity and a is acceleration. Write a program in java to print distance travelled. Make the program user friendly.

Answers

Answered by jeromeseejo73
3

import java. util. Scanner;

public class distanceCalculator

{

public static void main(String[] args)

{

Scanner sc= new Scanner(System.in);

System.out.println(" THE PROGRAM IS USER FRIENDLY ");

System.out.print(" Enter the time taken: ");

double t= sc.nextDouble();

System.out.print(" Enter the initial velocity: ");

double u= sc.nextDouble();

System.out.print(" Enter the acceleration: ");

double a= sc.nextDouble();

double d= u*t+(0.5*a*t*t) ;

System.out.println(" Distance travelled: "+d) ;

}

}

Similar questions