Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnkamara/1ed37b29bb3ff4ab18b2a6d0c2ebed49 to your computer and use it in GitHub Desktop.
Save johnkamara/1ed37b29bb3ff4ab18b2a6d0c2ebed49 to your computer and use it in GitHub Desktop.
Java - Coding Challenge 2 - MegaBytes Converter
public class MegaBytesConverter {
public static void printMegaBytesAndKiloBytes(int kiloBytes){
if (kiloBytes < 0){
System.out.println("Invalid Value");
} else {
int megabytes = (kiloBytes/1024);
int kiloRemainder = kiloBytes%1024;
System.out.println(kiloBytes+" KB = "+megabytes+" MB and "+kiloRemainder+" KB");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment