File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments