I am a complete java novice. If you could help me out that would be great. So I need to write a program, that makes money transaction. The way i wrote it is as follows:
class program
{
public static void main (String[] param)throws IOException
{
intro();
System.exit(0);
}
public static void intro()throws IOException
{
PrintWriter x =new PrintWriter(new FileWriter("data.txt"));
while (true)
{
Object[] possibleValues = { "Transfer", "Receive", "Cancel"};
Object selectedValue = JOptionPane.showInputDialog(null,"Choose one", "Input",JOptionPane.INFORMATION_MESSAGE, null, possibleValues, possibleValues[0]);
String name;
String surname;
String amount;
String info;
if(selectedValue.equals(possibleValues[0]))
{
name = JOptionPane.showInputDialog(null, "recipients name");
surname = JOptionPane.showInputDialog(null, "recipients surname");
amount = JOptionPane.showInputDialog(null, "amount");
info = name+surname+amount;
x.println(info);
}
else if(selectedValue.equals(possibleValues[1]))
{
String inputname;
String inputsurname;
String inputamount;
inputname = JOptionPane.showInputDialog(null, "your name");
inputsurname = JOptionPane.showInputDialog(null, "your surname");
inputamount = JOptionPane.showInputDialog(null, "amount");
String inputinfo = inputname + inputsurname + inputamount;
if(x.contains.String(inputinfo))
{
JOptionPane.showMessageDialog(null,"you will recieve "+inputamount+"$");
}
else
{
JOptionPane.showMessageDialog(null,"request not found");
}
}
else if(selectedValue.equals(possibleValues[2]))
{
x.close();
System.exit(0);
}
}
}
}
and everything seems to be working except for the:
If (x.contains.String(inputinfo))
line
basically what this program should do is that when you're making transaction it takes down the persons firstname surname and amount you want to give them and stores it in data.txt and when the person wants to collect the money writes down his name and surname and amount he should be receiving and if that information matches to the one stored in the data.txt the program tells them that they will receive the amount but if it doesn't match then the program will tell them that request wasn't found.
The part with the program storing the names and amounts in data.txt works; only the part that finds it doesn't. Please help.