我们正在做一个小组作业。该程序的一部分是供用户输入“支付”,然后输入学生的 SIN(社会保险号码)和从他们的帐户中扣除的金额。例如,pay,193678187,900。  
SIN 与文件中的 SIN 列表进行比较,生成到数组中并进行比较curSin.equals(stuSin))。  curSin并且stuSin都是字符串。
如果找到 SIN,它将从学生的余额中减少金额(未显示)并将其写入文件write(student,inrec)。
如果未找到 SIN,则应返回“未找到 SIN”。
我们的问题是,即使找到了 SIN,它仍然返回“SIN not found”。我们认为它与 if 语句和不等于比较有关,但我们已经尝试了所有我们能想到的方法,但无法让它正常工作。
任何帮助将不胜感激。谢谢。
下面的代码片段。
    if (cmd.equals("pay") && p.length == 3)
    { // first word is "pay";three terms (cmd, sin, $)
        System.out.println("pay");
        // Pay: decreases student payment, notifies of overpayment
        String stuSin = p[1];
        double stupay = Double.parseDouble(p[2]);
        for (int i = 0; i < student.length; i++)
        {
            Student x1 = student[i];
            String curSin = x1.getSin();
            if (curSin.equals(stuSin))
            {
                double curpay = x1.getBal();
                double newBal = curpay - stupay;
                if (stupay > curpay)
                {
                    JOptionPane.showMessageDialog(null, "Overpayment");
                    System.exit(0);
                }
                x1.setBal(newBal);
                System.out.println(x1.getBal());
                write(student, inrec);
            }
            else if (!curSin.equals(stuSin))
            {
                JOptionPane.showMessageDialog(null, "SIN not found"); // sin not found
                System.exit(0);
            }
        }// end of for loop
    }