
Write a program that displays the following table (note that 1 mile is 1.609 kilometers).
Miles Kilometers
1.609
3.218
���. 10 10.090

import java.text.*;
class ConvertMilesToKilometer
{
public static void main(String[] args)
{
DecimalFormat df=new DecimalFormat("##.###");
double miles[]={1,2,10};
for(int i=0;i<miles.length;i++){
double km = miles[i] * 1.609;
System.out.println(miles[i]+"\t "+df.format(km));
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.