Monday, 30 October 2017

Introduction to Java program



Problem 1.10
Assume a runner runs 14 kilometers in 45 minutes and 30seconds. Write a program that displays the average speed in miles per hour. (Note that 1 mile is 1.6 kilometers.)
       
Descripition:
                        By using formula   S=V * T
Solution:
          public class Message {

    public static void main(String[] args) {
          float inKM=14f,mile;
          mile=inKM/1.6f;
         
          System.out.println("  "+(45.3f/60)*mile);
    }
   
}

Output
               
                        


No comments:

Post a Comment