-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdistance.java
More file actions
31 lines (22 loc) · 922 Bytes
/
distance.java
File metadata and controls
31 lines (22 loc) · 922 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
26
27
28
29
30
31
import java.util.Scanner;
public class distance
{
/* Program that prompts users for and reads integer values for speed and distance traveled then prints the time required for trip as a floating point result
time traveled = distance traveled / rate
distance = speed x time
*/
public static void main(String[] args)
{
int rate;
int distance_traveled;
float travel_time;
Scanner RateTravel = new Scanner(System.in);
System.out.println("What is the speed traveled?");
rate = RateTravel.nextInt();
Scanner myDistance = new Scanner(System.in);
System.out.println("What is the distance traveled");
distance_traveled = myDistance.nextInt();
travel_time = distance_traveled / rate;
System.out.println("Travel Time" + travel_time + " Hours");
}
}