Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | IT Developer <?php echo $page_title; ?>
IT Developer

Mathematical Library Methods

Chapter 7

Mathematical Library Methods

Class 10 - Logix Kips ICSE Computer Applications with BlueJ


Share with a Friend

Java Program: Final Velocity Calculation


14. Write a program in Java to compute the final velocity of a vehicle using the following formula:

          v2 = u2 + 2as

where, u = initial velocity, a = acceleration and s = distance covered; they are entered by the user.

Given Formula

Java Programs

Where:

  • u = initial velocity
  • a = acceleration
  • s = distance covered

import java.util.Scanner;

 

public class FinalVelocity {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

 

        // Input values

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

        double u = sc.nextDouble();

 

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

        double a = sc.nextDouble();

 

        System.out.print("Enter distance covered (s): ");

        double s = sc.nextDouble();

 

        // Calculate final velocity

        double v = Math.sqrt((u * u) + (2 * a * s));

 

        // Output

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

 

        sc.close();

    }

}

Output


Sample Input 
Enter initial velocity (u): 10
Enter acceleration (a): 2
Enter distance covered (s): 50

Sample Output 
Final velocity (v) = 17.320508075688775

Explanation

  1. The program takes u, a, and s from the user using the Scanner class.
  2. It calculates u2+2as using arithmetic operators.
  3. Math.sqrt() is used to find the square root to obtain the final velocity.
  4. The result is displayed.