You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Create a integer variable kiloBytes and take a input from the user in kiloBytes. Now, create a method named printMegaBytes(int kiloBytes) and convert the kiloBytes into MegaBYtes.
// For example, if we divide the Kilobytes by 1024 , It will give the Megabytes(MB).
importjava.util.*;
publicclassMegaBytesConverter {
publicstaticvoidprintMegaBytes(intkiloBytes){
if (kiloBytes < 0){
System.out.println("Invalid Value");
} else {
intmegabytes = (kiloBytes/1024);
intkiloRemainder = kiloBytes%1024;
System.out.println(kiloBytes+" KB = "+megabytes+" MB and "+kiloRemainder+" KB");