Java Program to Meters to Kilo Meters

Description

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

Solution

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

Explanation

Get meter mts as input  (using scanner class)

Calculate kilometer km by dividing meter  mts by 1000. (km=mts/1000, 1000 meter is equal to 1 kilometer)
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