public class MegaBytesConverter {
public static void main(String[] args) {
printMegaBytesAndKiloBytes(2500);
printMegaBytesAndKiloBytes(-1024);
printMegaBytesAndKiloBytes(5000);

}

public static void printMegaBytesAndKiloBytes(double KB) {
// KB / 1024 = MB
double MBValue = KB / 1024;
int MB = (int) (MBValue);
if (KB > 0) {
System.out.println(KB + " KB is " + MB + " MB and " + KB % 1024 + " KB");
}
else {
System.out.println(KB + " KB is not real");
}


}


}
C:\Users\netadmin\.jdks\openjdk-23.0.1\bin\java.exe "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2024.2.4\lib\idea_rt.jar=55363:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2024.2.4\bin" -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath C:\Users\netadmin\IdeaProjects\MegaBytesConverter\out\production\MegaBytesConverter MegaBytesConverter
2500.0 KB is 2 MB and 452.0 KB
-1024.0 KB is not real
5000.0 KB is 4 MB and 904.0 KB

Process finished with exit code 0