Anyone who use Java?

Write here if you have problems with your Java source code

Moderator: Board moderators

Post Reply
Zhao Le
Learning poster
Posts: 80
Joined: Mon May 05, 2003 4:09 am
Location: Shanghai,China

Anyone who use Java?

Post 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 .
AC makes me feels good,
But WA makes me thinks hard.
UFP2161
A great helper
Posts: 277
Joined: Mon Jul 21, 2003 7:49 pm
Contact:

Post 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]
Larry
Guru
Posts: 647
Joined: Wed Jun 26, 2002 10:12 pm
Location: Hong Kong and New York City
Contact:

Post 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...
Ruslan Shevelyov
New poster
Posts: 15
Joined: Fri Aug 08, 2003 8:13 pm
Location: Russia, Moscow
Contact:

Re: Anyone who use Java?

Post by Ruslan Shevelyov »

Zhao Le, take a look at this thread.
www.Find-a-Drug.org distributed computing project
Post Reply

Return to “Java”