Page 1 of 1

Anyone who use Java?

Posted: Tue Aug 12, 2003 11:33 am
by Zhao Le
sorry for posting here,because in Java there is no one can help me.

how could I input v & t;

[java]import java.io.*;
public class sample
{
public static void main(String args[])
{
int v,t;
v=intRead();
t=intRead();
System.out.println(2*v*t);
}
}[/java]

Thanks.
or just tell me how to input float,double .

Posted: Tue Aug 12, 2003 4:04 pm
by UFP2161
I'm not a Java user on this site, so I don't even know if the Judge supports the following (I doubt it actually), but normally, one could do something like this:
[java]import java.io.*;

public class Sample
{
private static BufferedReader stdin =
new BufferedReader (new InputStreamReader (System.in));

public static void main (String[] args)
throws IOException
{
String input = stdin.readLine ();
int number = Integer.parseInt (input);
System.out.println (number);
}
}[/java]
This would only get one number PER line. If you knew there was more than one number on a line, then you would need to use (with the above methodoloy, though there's got to better ways!) StringTokenizer to parse the "input" string into it's component parts, and you can then parse each token however you want.

I also believe there's a thread about ACMIO.java (or something like that) around here somewhere too. You might want to take a look at that as well.[/java]

Posted: Tue Aug 12, 2003 5:56 pm
by Larry
Unforunately, the UVA judge's Java does NOT support Double.parseDouble, if I recall correctly.. unless they fixed that...

So it's a pain...

Re: Anyone who use Java?

Posted: Fri Aug 15, 2003 4:51 am
by Ruslan Shevelyov
Zhao Le, take a look at this thread.