Marathon /* * Marathon program (filename Marathon.java) * Created by 1,000_naymes for ICT 352 * Program informs a user of the distance of a marathon (26 miles, 385 yards) in * miles and kilometers. */ import java.util.Scanner; public class Marathon { public static void main( String[] args ) { // declaring & initiating variables String OutputMessage; double distanceMiles, distanceKilometers; // welcome message System.out.print("The distance of a marathon is 26 miles and 385 yards. \n\n This program will convert the distance to miles and kilometers. \n \n"); distanceMiles = (( 26 * 1760.00 ) + 385) / 1760.00; distanceKilometers = ( 1.609344 * 26 ) + ((385 / 1760) * 1.609344); OutputMessage = "The exact distance of a marathon in miles is " + distanceMiles + "\n" + "The exact distance in kilometers is " + distanceKilometers; System.out.println( OutputMessage ); } }
Page 1