Just started a java module at University, and im trying to teach myself some of the basics. But im really having some problems getting to grips with it.
At the moment, im just trying to make a program that reads users inputs, and does things with them. But im getting errors i can't seem to fix!
I have 2 files.
Text.java
/* Based on Text.class in Java Gently by Judy Bishop */ /* Ken Brownsey 10/6/00 */ import java.io.*; import java.util.*; public class Text { public Text() { } private static StringTokenizer tokens; private static String str; private static void Refresh(BufferedReader in) { try { str = in.readLine(); } catch(Exception e) { System.out.println("Refresh fail"); } tokens = new StringTokenizer(str, "\n"); } public static void Prompt (String str) { System.out.print(str + " "); System.out.flush(); } public static int ReadInt(BufferedReader in) { String item; if (tokens == null) { Refresh(in); } for(;true;) { try { item = tokens.nextToken(); return Integer.valueOf(item.trim()).intValue(); } catch(NoSuchElementException e1) { Refresh(in); } catch(NumberFormatException e2) { System.out.println("Number format exception - try again"); } } } public static char ReadChar(BufferedReader in) { if (tokens == null) { Refresh(in); } for(;true;) { try { return tokens.nextToken().charAt(0); } catch(NoSuchElementException e1) { Refresh(in); } } } public static double ReadDouble(BufferedReader in) { String item; if (tokens == null) { Refresh(in); } for(;true;) { try { item = tokens.nextToken(); return Double.valueOf(item.trim()).doubleValue(); } catch(NoSuchElementException e1) { Refresh(in); } catch(NumberFormatException e2) { System.out.println("Number format exception - try again"); } } } public static String ReadString(BufferedReader in) { String item; if (tokens == null) { Refresh(in); } for(;true;) { try { return tokens.nextToken(); } catch(NoSuchElementException e1) { Refresh(in); } } } }
Thats the code for getting the text from the input etc.. Was not made by me, but was supplied by the university
And my little bit of code....
/* * Hello World.java * * Created on 06 June 2005, 09:39 * */ package helloworld; /* *Created by Christopher Murray */ import java.io.*; public class Main { static private BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); public static void main(String[] args) { double amount; System.out.println("How Much for the Monkey?"); amount = Text.ReadDouble(in); amount = amount +25.00; System.out.print("We will Bill $"); System.out.print(amount); System.out.println("To your Credit Card"); System.out.println("Have a good day!"); } }
The error is on the line "amount = Text.ReadDouble(in);"
Claims it Can't find Symbol. And the symbol is the vairable "Text"
But as far as i can tell from all my lecture notes, it should be correct. :-/
Any ideas?