Java Program to calculate kilobytes to bytes

Description

Get kilobytes kb from user and find bytes b
Input 1:
2
Output1:
2048
Input2:
1
Output2:
1024

Solution

import java.util.*;
class KiloToByt
{
   public static void main(String args[])
   {
       int kilobytes,bytes;
       Scanner sc=new Scanner(System.in);
       System.out.println("Enter The KiloBytes:");
       kilobytes=sc.nextInt();
       bytes=kilobytes*1024;
       System.out.println("The Bytes Is:"+bytes);
   }
}

Explanation

Get kilobytes Kilo as input (using scanner class) 

Calculate bytes Byt by multipllying kilobytes  with 1024. (Byt=Kilobyte*1024, 1024 byts is equal to 1 kilobyte)

Print bytes Byt (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: [email protected]





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