hey guys , I would like to read info from a file e.g
999990 Gerry Boudens
999991 Jimmy Chow

it is a credit card program, so the user would input their name and the program searches for it, if found it should show their credit card number and balance.Also users are suppose to be able to call them to display individually as well as be able to change these values.

My code is below, any HELP would be greatly welcomed, even references that will help me.

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

public class MyFileReader{

  public static void main(String[]args)throws java.io.IOException
    Scanner fileInput = new Scanner(new File("a2.txt"));
    //java.io.File file = new java.io.File("a2.txt");
     //Scanner fileInput = new Scanner(file);
    PrintStream output = System.out;
    Scanner input = new Scanner(System.in);
    int count = 0;
     String Quit = null;   
    output.println("MAIN MENU");
    output.println("1 - Make purchase");
    output.println("2 - Make payment");
    output.println("3 - Change credit limit");
    output.println("4 - View credit limit");
    output.println("5 - View credit card balance");
    output.println("6 - View credit record");
    output.println("7 - Output entire database");
    output.println("Quit -    Exit database");
    output.println("Enter the number refered to your selection: ");
    String inputs = input.nextLine();

    for (; !inputs.equals("Quit"); inputs = input.nextLine())
     if     (inputs.equals("1"))
             output.println ("Enter full name of the card holder");
             String chname = input.next();
       for  (; fileInput.hasNext() ;)
      {     String temp2 = fileInput.next().toLowerCase(); 
            String temp = chname.toLowerCase();
       if  (temp.equals(temp2))
         {  output.println("Enter Purchase amount: "  );
      }//close of for name on file         
           output.println("Name not in Database: "  );  
     }//close of if choose 1
      if   (inputs.equals("7"))
        for (; fileInput.hasNext() ;)
         String temp2 = fileInput.next(); 
     }//close of if choose 7
   }// main for statement

also: if I enter a name to be searched in the file, it only recognises the first name:

9 Years
Discussion Span
Last Post by Ezzaral

My problem is I cant get to call the entire name of the individual, the credit limit and the credit card number separatly, which would help in me displaying the users info, when his/her name is found.


hey wats up guys, I have a text file that stores database of clients names and bank info, I entered the info into an array but dont kn0w how to run a query based on user input?? help please this is my code

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.*;
import java.util.*;

public class WordReader {
public static void main( String[] args ) {
String Bebe;

PrintStream output = System.out;
Scanner input = new Scanner(System.in);
// will store the words read from the file
List<String> wordList = new ArrayList<String>();

BufferedReader br = null;
try {
// attempt to open the words file
br = new BufferedReader( new FileReader( "a2.txt" ) );

String word;

// loop and read a line from the file as long as we dont get null

while( ( word = br.readLine() ) != null )
// add the read word to the wordList
wordList.add( word );
} catch( IOException e ) {
} finally {
try {
// attempt the close the file
} catch( IOException ex ) {

// initialize a new string array equal to the size of thewordList

String[] words = new String[ wordList.size() ];

// call the wordList's toArray method to and transfer itemsfrom

// wordList to our string array words
wordList.toArray( words );

// loop and display each word from the words array
for( int i = 0; i<words.length; i++)





i need to write a program about travel expenses
in chapter 7 challenging program
starting out with java
is there anybody who gives me the program?>
im so appreciate


No, you have come to the wrong site if you want a program given to you.

If you start a new thread, post your code, and ask specific questions, someone may be able to help you with it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.