Computer Science, asked by kshraddhasri123, 2 months ago

create a class equation and a function double calculate() with three parameters velocity u, time t, and accerlation acc all of double types . find and return the value of 'v' using v=u+at. write a main function (caller) to input value for u,a,t and by calling function calculate(). print the value of u,a,t and v

Answers

Answered by onlineexams000
0

The program is in the file along with output

Attachments:
Answered by Anushkaphokane
0

Answer:

import java.util.*;

public class distance

{

   double distance(double u, double time, double acc)

   {

       double d;

       d = (u*time) + ((1/2)*acc*(time*time));

       return d;

   }

   void main()

   {

       Scanner sc = new Scanner(System.in);

       double v,t,a,result;

       System.out.println("Enter the following data");

       System.out.print("Enter velocity(v)=");

       v=sc.nextDouble();

       System.out.print("Enter time(t)= ");

       t= sc.nextDouble();

       System.out.print("Enter acceleration (a)= ");

       a= sc.nextDouble();

       result= (distance(v,t,a));    

       System.out.println("The results are: ");

       System.out.println("velocity (v)= "+v);

       System.out.println("Time (t)= "+t);

       System.out.println("Acceleration (a)= "+a);

       System.out.println("Final result (d)= "+result);

   }

}

Explanation:

Similar questions