Sunday, November 1, 2015

// // Leave a Comment

Java Program To Calculate Average Speed In Kilometers

Solution to Liang's Introduction to Java Exercise 1.12

/**
 *
 * @Author: Aghatise Osazuwa
 * Website: www.cscprogrammingtutorials.com
 *
 * Exercise 1.12 - Average Speed In Kilometers
 *
 */ 

public class Ex1_12 {
  public static void main(String[] args) {
    System.out.println("Distance = 24 miles =" + (24.0 * 1.6) + " kilometers\n");
    System.out.println("Time = 1 hour 40 minutes 35 seconds" + " = "
       + (1 + (((40.0 * 60.0) + 35.0) / 3600)) + " hours.\n");
    System.out.print("Average Speed In kilometers per hour = ");
    System.out.println(((24.0 * 1.6) / (1 + (((40.0 * 60.0) + 35.0) / 3600)))
       + " kph.");
 }
}
Liang's Introduction to Java Exercise 1.12
Program Output

Click here to see other solutions to Introduction to Java Programming.

0 comments:

Post a Comment


DISCLAIMER: Opinions expressed in comments are those of the comment writers alone and does not reflect or represent the views of the post author. We reserve the right to delete any post deemed inappropriate or offensive and/or spammy. Please do not use abusive words/hate speech.

I Appreciate your valuable Feedback. So, Please DO NOT SPAM - Spam comments will be deleted immediately.

Don't use brand name in name field and you're not allowed to use links in comments unless it's necessary. Such comments will be removed immediately.

Thanks.