Results 1 to 6 of 6
  1. #1
    MasFlowKiller is offline Member
    Join Date
    Dec 2008
    Posts
    5
    Rep Power
    0

    Default ATM Program HELP

    ok so i have this file and in it, it has:
    lastName firstName accountNumber accountPassword accountBalance

    so i want my program to ask the user for the accountNumber and the accountPassword and to go into the file i have and check if they match and if the do it prints the firstName and lastName.

    so far i cant make it check and match accountNumber and the accountPassword and it prints everything in the file, i know i have to implement so type of array

    atmFile(String lastName, String firstName, int accountNumber,int accountPassword, double accountBalance) but i just cant make it work, any tips?

  2. #2
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    10

    Default Let's see ...

    Please post the code you have and rememeber to use the "code" button above (#).

    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  3. #3
    MasFlowKiller is offline Member
    Join Date
    Dec 2008
    Posts
    5
    Rep Power
    0

    Default

    wat code button?

  4. #4
    MasFlowKiller is offline Member
    Join Date
    Dec 2008
    Posts
    5
    Rep Power
    0

    Default

    import java.util.Scanner;
    import java.io.DataInputStream;
    import java.io.FileInputStream;
    import java.io.InputStreamReader;
    import java.io.PrintStream;
    import java.io.PrintWriter;
    import java.io.FileNotFoundException;
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.FileOutputStream;
    import java.io.File;
    import java.util.Scanner;
    import java.util.List;
    import java.util.ArrayList;
    public class ATM
    {
    private String accountFile;
    private String password;
    private String lastName;
    private String firstName;
    private int accountNumber;
    private int accountPassword;
    private double accountBalance;

    void set(String lastName, String firstName, int accountNumber,int accountPassword, double accountBalance) throws FileNotFoundException
    {
    FileInputStream inFile;
    inFile = new FileInputStream ("C:\\Documents and Settings\\fortind\\My Documents\\ATM\\ATM.txt");
    System.out.println(lastName);

    }
    public void read()
    {

    FileInputStream inFile;
    try
    {
    // Open an input stream
    inFile = new FileInputStream ("C:\\Documents and Settings\\fortind\\My Documents\\ATM\\ATM.txt");

    // Read a line of text
    System.out.println( new DataInputStream(inFile).readLine() );

    // Close our input stream
    inFile.close();
    }
    // Catches any error conditions
    catch (IOException e)
    {
    System.err.println ("Unable to read from file");
    System.exit(-1);
    }

    }
    public void write()
    {

    // Stream to write file
    FileOutputStream outFile;

    try
    {
    // Open an output stream
    outFile = new FileOutputStream ("C:\\Documents and Settings\\fortind\\My Documents\\ATM\\ATM.txt");

    // Print a line of text
    new PrintStream(outFile).println ("Test");

    // Close our output stream
    outFile.close();
    }
    // Catches any error conditions
    catch (IOException e)
    {
    System.err.println ("Unable to write to file");
    System.exit(-1);
    }

    }

    }

  5. #5
    MasFlowKiller is offline Member
    Join Date
    Dec 2008
    Posts
    5
    Rep Power
    0

    Default

    public class ATMDemo {
    public static void main(String[] args)
    {
    ATM A1 = new ATM();
    A1.read();
    //A1.write();
    A1.set(null, null, 0, 0, 0);



    }
    }

  6. #6
    MasFlowKiller is offline Member
    Join Date
    Dec 2008
    Posts
    5
    Rep Power
    0

    Default

    i just dont know what to do next, the rest of the code depends on the program reading the file right

Similar Threads

  1. Executing a program within a program
    By gibsonrocker800 in forum New To Java
    Replies: 5
    Last Post: 05-12-2008, 08:24 AM
  2. Replies: 0
    Last Post: 04-04-2008, 02:40 PM
  3. cannot run the program
    By amiey in forum New To Java
    Replies: 1
    Last Post: 11-20-2007, 05:13 AM
  4. Replies: 0
    Last Post: 10-04-2007, 09:33 PM
  5. Why does this program not end?
    By trill in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 07:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •