So i am supposed to write a program where you can enter any number of bytes in the input and it is supposed to tell you how many gigabytes, megabytes, kilobytes, and bytes you just entered was. I will post down below what I have so far but I am stumbled. I know somehow you can use the Math.pow functions since KB is 2^10th bytes, and MB is 2^20 bytes, and GB is 2^30 bytes. I am just unsure on how to implement them. Thanks for your help!
While posting code, make sure to UseCodeTags, it makes code readable and easier to understand.
Now coming to your problem, are you required to mention the bytes in GB, MB and KB or just the nearest unit.
Either case, you should not require the use of Math.pow(). Simply dividing the number by 1024 repeatedly gives you the required unit.
And since you are using division, you are better off using doubles instead of ints.
For example 898745489 bytes is 877681.1416 KB, 857.11049 MB or 0.83702 GB.
There is a way of getting KiB, MiB, GiB and TiB as integers by using the division and remainder operators together. You can read about those operators in the Java® Language Specification, but that can be difficult to understand. If you want GiB you are better off with a long than with an int, to give you enough capacity for all the digits.
There is another way to get those figures with the bitshift and bitwise AND operators, but that is an advanced topic.
By the way: there are two measurement types. There are kB. MB, GB and TB which go up in ratios of 1000, and there are KiB MiB GiB and Tib which go up in ratios of 2¹⁰ = 1024. Knowing that removes the need to use Math#pow, a Amit has already told you. It probably doesn't matter whether you use 1024 or 1000, but maybe you should ask about that.