SHARE
TWEET

Untitled

a guest Jul 18th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Write a method called printMegaBytesAndKiloBytes that has 1 parameter of type int with the name kiloBytes.
  2.  
  3. The method should not return anything (void) and it needs to calculate the megabytes and remaining kilobytes from the kilobytes parameter.
  4.  
  5. Then it needs to print a message in the format "XX KB = YY MB and ZZ KB".
  6.  
  7. XX represents the original value kiloBytes.
  8. YY represents the calculated megabytes.
  9. ZZ represents the calculated remaining kilobytes.
  10.  
  11. For example, when the parameter kiloBytes is 2500 it needs to print "2500 KB = 2 MB and 452 KB"
  12.  
  13. If the parameter kiloBytes is less than 0 then print the text "Invalid Value".
  14.  
  15.  
  16. EXAMPLE INPUT/OUTPUT
  17.  
  18. * printMegaBytesAndKiloBytes(2500); → should print the following text: "2500 KB = 2 MB and 452 KB"
  19.  
  20. * printMegaBytesAndKiloBytes(-1024); → should print the following text: "Invalid Value" because parameter is less than 0.
  21.  
  22. * printMegaBytesAndKiloBytes(5000); → should print the following text: "5000 KB = 4 MB and 904 KB"
  23.  
  24.  
  25. TIP: Be extremely careful about spaces in the printed message.
  26.  
  27. TIP: Use the remainder operator
  28.  
  29. TIP: 1 MB = 1024 KB
  30.  
  31. NOTE: Do not set kilobytes parameter value inside your method.
  32.  
  33. NOTE: The solution will not be accepted if there are extra spaces.
  34. NOTE: The printMegaBytesAndKiloBytes method  needs to be defined as public static like we have been doing so far in the course.NOTE: Do not add a  main method to solution code.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top