sorry just noticed that i can make it easier to read
this program is really starting to get the better of me mentaly.. can any one help me please ???
the idea of the program is so that it takes the info in the file wich is displayed as so
Darren Green 1234
and writes it to another file displayeing as
Darren Green 12345
then it should take the enterd users enterd number and compare it with the number read, if it matches it should print winner like so
Darren Green 12345 winner
if it only 4 numbers match it should say 4 out of 5 instead of winner and same with 3 and then two
this is the code i already have for this
this program is really starting to get the better of me mentaly.. can any one help me please ???
the idea of the program is so that it takes the info in the file wich is displayed as so
Darren Green
1234
and writes it to another file displayeing as
Darren Green 12345
then it should take the enterd users enterd number and compare it with the number read, if it matches it should print winner like so
Darren Green 12345 winner
if it only 4 numbers match it should say 4 out of 5 instead of winner and same with 3 and then two
this is the code i already have forthis
/* Generated by Together */
import java.io.*;
import javax.swing.*;
publicclass Match {
publicstaticvoid main(String[]args)
{
String [] name = new String[10];
String[] num = new String[10];
String[] ball = new String[10];
ball[0] = JOptionPane.showInputDialog("Please Enter Num");
int balls = Integer.parseInt(ball[0]);
try {
FileReader fr = new FileReader("Cust.txt");
BufferedReader inputBuffer = new BufferedReader(fr);
for (int i = 0; i < num.length; i++)
{
name = inputBuffer.readLine();
num = inputBuffer.readLine();
}
inputBuffer.close();
}
catch (FileNotFoundException e)
{
JOptionPane.showMessageDialog (null, "no file");
}
catch (IOException e)
{
JOptionPane.showMessageDialog (null,"Mhhee");
}
try {
FileWriter outputFile = new FileWriter("Res.text");
PrintWriter outFile = new PrintWriter (outputFile);
outFile.print(name[0]+ "\t ");
outFile.print(num[0]+ " ");
outFile.close();
}
catch (IOException e)
{ }
JOptionPane.showMessageDialog (null, "Error");
}
{
for(int y = 0; y < num.length; y++)
{
if (num[y].equals(balls))
{
try {
FileWriter outputFile = new FileWriter("Res.text", true);
PrintWriter outFile = new PrintWriter (outputFile);
outFile.print(balls + " ");
outFile.print("Winner");
outFile.close();
}
catch (IOException e)
{ }
JOptionPane.showMessageDialog (null, "Error"); //exception catches incase files are not found}
}
else
{
try {
FileWriter outputFile = new FileWriter("Res.text", true);
PrintWriter outFile = new PrintWriter (outputFile);
outFile.print(balls + " ");
outFile.print("4 out of 5");
outFile.close();
}
catch (IOException e)
{ }
JOptionPane.showMessageDialog (null, "Error"); //exception catches incase files are not found}
}
}
}
}
the other proble i have is that it is already spitting out errors with regars to the variables used in the last two try and catch stamnets and the "for(int y = 0; y < num.length; y++) { if (num[y].equals(balls))"
part of the code the genneral reading and writing works but guess thats the easy part,,, aby help would be gretaly apprieciated... thanks the other proble i have is that it is already spitting out errors with regars to the variables used in the last two try and catch stamnets and the "for(int y = 0; y < num.length; y++) { if (num[y].equals(balls))"
part of the code the genneral reading and writing works but guess thats the easy part,,, aby help would be gretaly apprieciated... thanks