-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDistanceTime.java
More file actions
25 lines (25 loc) · 832 Bytes
/
DistanceTime.java
File metadata and controls
25 lines (25 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import java.util.Scanner;
class DistanceTime
{
public static void main(String [] args)
{
//speed=distance/time
Scanner ref = new Scanner(System.in);
System.out.print("Enter total distance ");
float dist = ref.nextFloat();
System.out.println("Case 1");
System.out.print("Enter speed");
int s1 = ref.nextInt();
float Time1 = dist/s1;
System.out.println("Time to Reach SriLanka = "+ Time1+" hr");
System.out.println("Case 2");
System.out.print("Enter speed");
int s2 = ref.nextInt();
float Time2 = dist/s2;
System.out.println("Time to Reach Back = "+Time2+ " hr");
System.out.println("Case 3");
System.out.print("Enter total party time");
int party = ref.nextInt();
System.out.println("Total time taken is = "+ (Time1+Time2+party) +" hrs");
}
}