We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c99311f commit fb4f767Copy full SHA for fb4f767
Train.java
@@ -0,0 +1,19 @@
1
+import java.util.Scanner;
2
+public class Train
3
+{
4
+ public static void main (String [] args)
5
+ {
6
+ Scanner scan = new Scanner (System.in);
7
+ System.out.println ("Please enter 4 integers ");
8
+ System.out.println ("Please enter the speed of train 1:");
9
+ int v1 = scan.nextInt();
10
+ System.out.println ("Please enter the time of train 1:");
11
+ int t1 = scan.nextInt();
12
+ System.out.println ("Please enter the speed of train 2:");
13
+ int v2 = scan.nextInt();
14
+ System.out.println ("Please enter the time of train 2:");
15
+ int t2 = scan.nextInt();
16
+ int dis = Math.abs(((t1 / 60) * v1) - ((t2 / 60) * v2));
17
+ Systen.out.println (" The distance between the trains is " + dis + "km");
18
+ } // end of method main
19
+} //end of class Train
0 commit comments