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
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
India Languages,
3 months ago
Economy,
3 months ago
Chemistry,
7 months ago
Math,
7 months ago
Math,
11 months ago