-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpeedCalculator_mph.java
More file actions
22 lines (21 loc) · 928 Bytes
/
SpeedCalculator_mph.java
File metadata and controls
22 lines (21 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.util.Scanner;
public class SpeedCalculator_mph {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println(" -----------------------");
System.out.println(" SPEED IN MILES PER HOUR");
System.out.println(" -----------------------");
System.out.print("Kindly Enter Distance in Kilometers : ");
double kilometers = input.nextFloat();
double miles = kilometers / 1.6;
System.out.println("Enter Time: ");
System.out.print("_ hrs \r");
int hrs = input.nextInt();
System.out.print("_ mins \r");
int mins = input.nextInt();
System.out.print("_ secs \r");
int secs = input.nextInt();
double time = hrs + (mins / 60.0) + (secs / 3600.0);
System.out.printf("Dear Customer %.2f Miles Per Hour is your Average Speed", (miles / time));
}
}