Skip to content

Commit 1131a17

Browse files
committed
Velocity calculator added
1 parent a6dc605 commit 1131a17

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import java.util.Scanner;
2+
3+
public class VelocityCalculator {
4+
public static void main(String[] args) {
5+
Scanner scanner = new Scanner(System.in);
6+
7+
System.out.println("Velocity Calculator");
8+
System.out.print("Enter initial position (meters): ");
9+
double initialPosition = scanner.nextDouble();
10+
11+
System.out.print("Enter final position (meters): ");
12+
double finalPosition = scanner.nextDouble();
13+
14+
System.out.print("Enter time taken (seconds): ");
15+
double time = scanner.nextDouble();
16+
17+
// Calculate velocity using the formula: velocity = (final position - initial position) / time
18+
double velocity = (finalPosition - initialPosition) / time;
19+
20+
System.out.println("The velocity is " + velocity + " meters per second.");
21+
22+
scanner.close();
23+
}
24+
}

0 commit comments

Comments
 (0)