Results 1 to 6 of 6
Thread: ATM Program HELP
- 12-07-2008, 10:56 PM #1
Member
- Join Date
- Dec 2008
- Posts
- 5
- Rep Power
- 0
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?
- 12-07-2008, 11:01 PM #2
Let's see ...
Please post the code you have and rememeber to use the "code" button above (#).
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 12-07-2008, 11:04 PM #3
Member
- Join Date
- Dec 2008
- Posts
- 5
- Rep Power
- 0
wat code button?
- 12-07-2008, 11:05 PM #4
Member
- Join Date
- Dec 2008
- Posts
- 5
- Rep Power
- 0
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);
}
}
}
- 12-07-2008, 11:06 PM #5
Member
- Join Date
- Dec 2008
- Posts
- 5
- Rep Power
- 0
public class ATMDemo {
public static void main(String[] args)
{
ATM A1 = new ATM();
A1.read();
//A1.write();
A1.set(null, null, 0, 0, 0);
}
}
- 12-07-2008, 11:08 PM #6
Member
- Join Date
- Dec 2008
- Posts
- 5
- Rep Power
- 0
Similar Threads
-
Executing a program within a program
By gibsonrocker800 in forum New To JavaReplies: 5Last Post: 05-12-2008, 08:24 AM -
How to execute an External Program through Java program
By Java Tip in forum java.ioReplies: 0Last Post: 04-04-2008, 02:40 PM -
cannot run the program
By amiey in forum New To JavaReplies: 1Last Post: 11-20-2007, 04:13 AM -
How to execute an External Program through Java program
By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 09:33 PM -
Why does this program not end?
By trill in forum New To JavaReplies: 1Last Post: 08-07-2007, 07:22 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks