Re: How can a user type in an int value?
From: gajo (gajo_at_eunet.yu)
Date: 10/19/03
- Next message: Darryl L. Pierce: "Re: simple Math question"
- Previous message: lucien: "Re: graphics problems using jre1.4.2?"
- In reply to: Gordon Beaton: "Re: How can a user type in an int value?"
- Next in thread: ge0rge: "Re: How can a user type in an int value?"
- Reply: ge0rge: "Re: How can a user type in an int value?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 19 Oct 2003 14:30:33 +0200
"Gordon Beaton" <not@for.email> wrote in message
news:3f926a75$1@news.wineasy.se...
> Then do Integer.parseInt(line) to get the value from the line.
Do I need to import the parseInt method from somewhere? Cause I get the
following error:
Faktoriel.java:16: cannot resolve symbol
symbol : method parseInt (int)
location: class java.lang.Integer
int i = Integer.parseInt(j);
^
Here's the whole code --->
import java.io.*;
class Faktoriel {
public static int F(int n) {
if (n<=1) return 1;
else return n*F(n-1);
}
public static void main (String [] arg) throws Exception {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Faktoriel program");
System.out.println(" ");
System.out.print("Type in a number: ");
int j = in.read();
int i = Integer.parseInt(j);
System.out.println(" ");
System.out.print(i+"! = ");
int k = F(i);
System.out.println(k);
}
}
- Next message: Darryl L. Pierce: "Re: simple Math question"
- Previous message: lucien: "Re: graphics problems using jre1.4.2?"
- In reply to: Gordon Beaton: "Re: How can a user type in an int value?"
- Next in thread: ge0rge: "Re: How can a user type in an int value?"
- Reply: ge0rge: "Re: How can a user type in an int value?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|