Joseph Abney

Greenhorn
+ Follow
since Nov 01, 2014
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Joseph Abney

Having some issues with my homework.
So i posted my code here yesterday and you all helped out alot, I really appreciate it. I am supposed to use integers for the user to enter an amount of bytes into the input, and it is supposed to output how many GBs, MBs, KBs, and bytes are in the amount of bytes that was entered. Here is my code so far but I am having a few errors.
package hw1.java;


I used the division and modulas like someone suggested (I figured that was how you were supposed to do it, and it runs and works for some inputs, say i entered 1073742849 bytes, then it will give me back 1 GB. but if enter a bigger number like 2500000000, it gives me this error.
"Exception in thread "main" java.util.InputMismatchException: For input string: "2500000000"
at java.util.Scanner.nextInt(Scanner.java:2123)
at java.util.Scanner.nextInt(Scanner.java:2076)
at hw1.java.Hw1Java.main(Hw1Java.java:17)"
Also something is wrong with the integer variable "mbs" bc when I enter a number to check how it is working, for example i would enter 1049600 bytes then it will give me an error and return this.
"Exception in thread "main" java.lang.ArithmeticException: / by zero
at hw1.java.Hw1Java.main(Hw1Java.java:25)
Java Result: 1"
Something about dividing by zero? Anyway thanks for everyone's help.
5 years ago
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!

5 years ago
Here is my code I am trying to make run but I am stuck. When I run it in terminal it says it cannot find symbol t.playTape();
6 years ago