Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help writing code for the following different selector\'s, inthis case i ha

ID: 3616734 • Letter: N

Question



Need help writing code for the following different selector's, inthis case i have a txt file with a bunch of names written in:
Don
Mary
Al
melissa
etc
etc

each with a newline after each name

I'm looking for some example code on how these selector's wouldfunction on selecting a name.

-Sequential selector: (selects each name form a list in Sequentialorder… after the name is selected, it resets and selects thefirst name again etc

-Random Selector: Selects a name at Random

-Conditional Selector: selects a name from the list based on whatwas typed in.(Not random)

-Timed Selector: selects a name from a list based on the timeelapsed since the last name was selected

Thx in advance Apahreus
(must be written in Java)

Explanation / Answer

public class cramfile
{
    public static void main(String args[])
{
       
try{
FileReader fr=new FileReader("contact.txt");
BufferedReader br=new BufferedReader(fr);
int flag=0;
while(flag==0)
{
    line=br.readLine();
System.out.println("Name: "+line);

if(line==null)
{
JOptionPane.showMessageDialog(null,"File Ended");
String input=JOptionPane.showInputDialog("Enter 0 to continue fromthe start of file");
flag=Integer.parseInt(input);
}

if(flag==0)
{
br.close();
fr.close();

try{
FileReader fr=new FileReader("contact.txt");
BufferedReader br=new BufferedReader(fr);
}catch(IOException ioex)
{
System.out.println(ioex);
}
}
}
br.close();
fr.close();
}catch(IOException ioex)
{
System.out.println(ioex);
}
return count;

}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote