You code works well, for instance a run of
import java.io.*;
class Meas
{
public static void main( String arg[]) throws IOException
{
BufferedReader userInput = new BufferedReader (new InputStreamReader(System.in));
System.out.println("Enter PlainText:");
String s = userInput.readLine();
double bytes = s.length();
double kilobytes = (bytes / 1024);
double megabytes = (kilobytes / 1024);
double gigabytes = (megabytes / 1024);
double terabytes = (gigabytes / 1024);
double petabytes = (terabytes / 1024);
double exabytes = (petabytes / 1024);
double zettabytes = (exabytes / 1024);
double yottabytes = (zettabytes / 1024);
System.out.println("bytes : " + bytes);
System.out.println("kilobytes : " + kilobytes);
System.out.println("megabytes : " + megabytes);
System.out.println("gigabytes : " + gigabytes);
System.out.println("terabytes : " + terabytes);
System.out.println("petabytes : " + petabytes);
System.out.println("exabytes : " + exabytes);
System.out.println("zettabytes : " + zettabytes);
System.out.println("yottabytes : " + yottabytes);
}
}
gave me
Enter PlainText:
That's all folks!
bytes : 17.0
kilobytes : 0.0166015625
megabytes : 1.621246337890625E-5
gigabytes : 1.5832483768463135E-8
terabytes : 1.546140993013978E-11
petabytes : 1.509903313490213E-14
exabytes : 1.474514954580286E-17
zettabytes : 1.4399560103323106E-20
yottabytes : 1.406207041340147E-23
Please note you may write it more tersely
import java.io.*;
class Meas
{
public static void main(String arg[]) throws IOException
{
String desc[] = new String [] { "bytes", "kilobytes", "megabytes", "gigabytes", "terabytes", "petabytes", "exabytes", "zettabytes", "yottabytes"};
BufferedReader userInput = new BufferedReader (new InputStreamReader(System.in));
System.out.println("Enter PlainText:");
String s = userInput.readLine();
double len = s.length();
for (String d : desc)
{
System.out.println( d + " : " + len);
len /= 1024;
}
}
}