Computer Science, asked by khushi159473, 7 months ago

Q1. Write a Java program to display the speed, in meters per second, kilometers per hour and miles per hour.
User Input : Distance (in meters) and the time was taken (as three numbers: hours, minutes, seconds).
Note : 1 mile = 1609 meters
Test Data
Input distance in meters: 2500
Input hour: 5
Input minutes: 56
Input seconds: 23
Sample Output:
Input distance in meters: 2500
Input hour: 5
Input minutes: 56
Input seconds: 23
Your speed in meters/second is 0.11691531
Your speed in km/h is 0.42089513
Your speed in miles/h is 0.26158804​

Answers

Answered by ArpitMishra506
6

Sorry I wasn't able to understand your question but here is what I think you want

import java.io.*;

public class Speed{

public static void main(String args[])throws IOException{

BufferedReader ob = new BufferedReader(new InputStreamReader(System.in));

int m=0;

int km=0

int mile=0;

int hr=0;

int min=0;

int sec=0;

int mps=0;

int kmph=0;

int mileph=0;

System.out.print("Input distance in metre : ");

m=Integer.parseInt(ob.readLine());

km=m/1000;

mile=m/1609;

System.out.print("Input hour : ");

hr=Integer.parseInt(ob.readLine());

System.out.print("Input minutes : ");

min=Integer.parseInt(ob.readLine());

System.out.print("Input seconds : ");

sec=Integer.parseInt(ob.readLine());

mps=m/sec;

kmph=km/hr;

mileph=mile/hr;

System.out.println(" Speed in metre per second "+mps);

System.out.println(" Speed in km per hour "+kmph);

System.out.println(" Speed in miles per hour "+mileph);

}

}

.

.

.

.

HOPE THIS HELPS YOU

.

.

.

.

PLEASE MARK AS BRAINLIEST AND FOLLOW ME TOO

Similar questions