Java Write Method Called Printmegabytesandkilobytes 1 Parameter Type Int Name Kilobytes Me Q43787941
(Java) Write a method called printMegaBytesAndKiloBytes that has1 parameter of type int with the name kiloBytes. The method shouldnot return anything (void) and it needs to calculate the megabytesand remaining kilobytes from the kilobytes parameter. Then it needsto print a message in the format “XX KB = YY MB and ZZ KB”. XXrepresents the original value kiloBytes. YY represents thecalculated megabytes. ZZ represents the calculated remainingkilobytes. For example, when the parameter kiloBytes is 2500 itneeds to print “2500 KB = 2 MB and 452 KB” If the parameterkiloBytes is less than 0 then print the text “Invalid Value”.
EXAMPLE INPUT/OUTPUT
*printMegaBytesAndKiloBytes(2500); → should print the followingtext: “2500 KB = 2 MB and 452 KB”
*printMegaBytesAndKiloBytes(-1024); → should print the followingtext: “Invalid Value” because parameter is less than 0.
*printMegaBytesAndKiloBytes(5000); → should print the followingtext: “5000 KB = 4 MB and 904 KB”
Expert Answer
Answer to (Java) Write a method called printMegaBytesAndKiloBytes that has 1 parameter of type int with the name kiloBytes. The me…
OR