-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpeedCalculator_kmph.java
More file actions
22 lines (21 loc) · 928 Bytes
/
SpeedCalculator_kmph.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_kmph {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println(" ----------------------------");
System.out.println(" SPEED IN KILOMETERS PER HOUR");
System.out.println(" ----------------------------");
System.out.print("Kindly Enter Distance in Miles: ");
double miles = input.nextFloat();
double kilometers = miles * 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 kmph is your Average Speed", (kilometers / time));
}
}