runtime error reading data from text file

From: Robocop (rob-cop_at_excite.com)
Date: 02/29/04


Date: 28 Feb 2004 16:21:23 -0800

Hi folks please help me figure out whats wrong with this code i have
shown which part is giving run time error (below code is the
datafile!).....

please read its pretty simple just few bugs !

import type.lang.*;
import type.lib.*;
import java.util.*;

public class Check0

{
 public static void main(String []args)
 {
  IO.println("Enter name, limit, and trx filename
(comma-delimited):");
  String finstr = "PCL";
  StringTokenizer tok = new StringTokenizer(IO.readLine() ,",");
  
  String name = tok.nextToken();
  String limit = tok.nextToken();
  String file = tok.nextToken();
  double num = Double.parseDouble(limit);
  CreditCard card = new CreditCard(2343,name,num);
  UniReader ur = new UniReader(file);
  
  int count = 0; //00001 counter
  
  for (String str = ur.readLine(); !ur.eof(); str = ur.readLine())
  {
   count++; //counts no. of records.
   StringTokenizer tok2 = new StringTokenizer(str);
   IO.print(count, "5Z");
   if(str == "")
   {
    IO.println(" invalid record.");
   }
   for (;tok2.hasMoreTokens();)
   {
   String tranin = tok2.nextToken().toUpperCase();
   String trancode = "" + tranin.charAt(0);
 //FOLLOWING PART IS GIVING RUNTIME ERROR!!!
   String stra = tok2.nextToken(); //gets p550.. from data file given
below
   
   IO.print(stra.charAt(0));
  if(finstr.charAt(finstr.indexOf(stra.charAt(0))) == stra.charAt(0));
  
 String stram = stra.substring(1, stra.length());
 //??????????????????OVER???????????????????????????????????/
   double amount = Double.parseDouble(stram);
   trancode.toUpperCase();
   
   IO.print(" "+trancode);
   IO.print(amount, "10.2");
   if (trancode.equals("C") && card.charge(amount))
   {
    IO.print(" done.","10.2L");
   }
   else if (trancode.equals("P"))
   {
     card.pay(amount);
     IO.print(" done.","10.2L");
   }
   else if (trancode.equals("L") && card.setLimit(amount))
   {
    IO.print(" " +"done.","10.2L");
   } else{
    IO.print(" " +"rejected.","10.2L");
   }
   IO.println();
   
   } //end of hasMoreTokens();
   
  } // end of tokenizer
   
  
  IO.print("Card Balance = ");
  IO.print(card.getBalance(), "10.2");
  IO.println();
  IO.print("Credit Limit = ");
  IO.print(card.getLimit(), "10.2");
   
   }
}

_____________________________

c 500
c 2100
   p550 // <==problem line
  c 5950
c 3000

l4000 // <== problem line
p 4050
        l 2500
c 2750
  p 500
c 200
  p 1000
_____________________________

thanks a lot for your help!!! :)



Relevant Pages

  • RE: Finding a value and then finding a value from that
    ... intHighestNumber = intHighestNumber + 1 ... string but each value separated by a /. ... I get a type mis-match run time error when using this. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Spaces in folder name and file name
    ... Const cstrDatabaseWB As String = "C:\Documents and Settings\5YPJB\My ... There is a space in the folder name "ACS AQ" and multiple spaces in the ... I'm getting a Run time Error 1004 Application/Object Defined Error ... I tried using single quotes inside the double quotes around the file name ...
    (microsoft.public.excel.programming)
  • Re: VBA Error "Type Mismatch"
    ... Tom Ogilvy wrote: ... variety of sources - most of which are string based but some times the ... string is converted from another source hence the data type variant. ... not generate the run time error. ...
    (microsoft.public.excel.programming)
  • RE: value with check box
    ... I am getting Run time error 438 ... Can I do instead of this string the default value for checkbox to no ... > Dim strDefaultValueAs String ...
    (microsoft.public.access.forms)