Java Program to Kilo Meters to Meters

Description

Get Kilometer km from user and find meter m
Input 1:
56
Output1:
56000

Solution

import java.util.*;
class KmToMts
{
     public static void main(String args[])
     {
          float km,metres;
          Scanner sc=new Scanner(System.in);
          System.out.println("Enter The Input 1:");
          km=sc.nextFloat();
          metres=km*1000;
          System.out.printf("The Output 1 Is:\n%.0f",metres);
      }
}

Explanation

Get kilometer km as input (using scanner class)  (since kilometer may be in fractional values like 1 and 5, it is declared & read as integer.) 

Calculate meter m by multipllying kilometer km with 1000. (m=km*1000, 1000 meter is equal to 1 kilometer)

print meter m. (using system.out.println)
Ramesh P Natarajan

Author - Ramesh P Natarajan

Learner, Professor, Technology Trainer, Software Developer and Content Marketer, very much passionate in the field of Software Application Development, Machine Learning and Search Engine Optimization.

Write to: admin@decodeschool.com





Interesting Pattern Programs: for more Patterns

Input:
5
Output:
*
**
***
****
*****
****
***
**
*Solution
Input:
5
Output:
    *
   ***
  *****
 *******
*********
 *******
  *****
   ***
    *Solution
Input:
5
Output:
*        *
**      **
***    ***
****  ****
**********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********
**** ****
***   ***
**     **
*       *Solution
Input:
5
Output:
*********
 *******
  *****
   ***
    *
   ***
  *****
 *******
*********Solution