public static void studentNumber() throws IOException
{
int word2;
int val = 0;
System.out.println("Enter the Student Number");
word2 = sc2.nextInt();
Scanner file = new Scanner(new File("data.txt"));
System.out.println();
while(file.hasNextLine())
{
String line = file.nextLine();
if(line.indexOf(word2) != -1)
{
System.out.println("The student" +word2+ " exists in our system, their phone number is");
val = 1;
break;
}
else
{
val = 0;
continue;
}
}
if(val == 0)
{
System.out.println("The student " +word2+ " does not exist in our system");
}
}
}
Allow the user to search for student data according to
- a. Surname and First Name
- b. Student number
- If the student exists: display their phone number(s) along with the name
- If the student does not exist, alert the user to this fact.
Here is an example of the list from my text file:
Barrett,Zulema,848284,M,3A1,3H2,S3,961025,2891374756, ,CHT3O0ACLU3M0BENG3C0EHIR3C0AMBF3C0CPPL3OMAPPL4OMCSBI3C0B