![]()
Write a program, named genpairs.cpp, to generate a list of random pairs of students. Each time you run your program, the list should be different.
You are to read data about students and generate a listing of random pairs of students. Each line of data is information about one student: the student's email address first, followed by a space, followed by the student's name (with blanks between parts of the name). However, your program should output the pairings in the format: student's first and last name, followed by their email address in parentheses. Note, if the student has any middle names, it should not be printed.Additionally, your program should ask the user to enter the name of the data file. There are three data files that you can use to test your program available online here.
For example, sec3.dat has the following (13 lines):
arjun.menon@duke.edu Menon, Arjun karl.mischke@duke.edu Mischke, Karl Robert edward.moulton@duke.edu Moulton, Edward James sandip.patel@duke.edu Patel, Sandip Pravin jonathan.pollock@duke.edu Pollock, Jonathan Richard ryan.rattet@duke.edu Rattet, Ryan Benjamin jason.robins@duke.edu Robins, Jason Daniel jeff.stanley@duke.edu Stanley, Jeffrey Christopher shao.tong@duke.edu Tong, Shao Chuen andrew.tupper@duke.edu Tupper, Andrew R andrew.vankirk@duke.edu Van Kirk, Andrew de la Ronde yevsyuko@duke.edu Yevsyukova, Mariya Sergeyevna christopher.zeiders@duke.edu Zeiders, Christopher Matthew
One run of the program might be (since the program is random, the output should be different each time you run it):
Enter filename: sec3.dat
Group 1
Arjun Menon (arjun.menon@duke.edu)
Sandip Patel (sandip.patel@duke.edu)
Group 2
Andrew Tupper (andrew.tupper@duke.edu)
Karl Mischke (karl.mischke@duke.edu)
Group 3
Jonathan Pollock (jonathan.pollock@duke.edu)
Mariya Yevsyukova (yevsyuko@duke.edu)
Group 4
Shao Tong (shao.tong@duke.edu)
Ryan Rattet (ryan.rattet@duke.edu)
Group 5
Edward Moulton (edward.moulton@duke.edu)
Christopher Zeiders (christopher.zeiders@duke.edu)
Group 6
Jason Robins (jason.robins@duke.edu)
Jeffrey Stanley (jeff.stanley@duke.edu)
Andrew Van Kirk (andrew.vankirk@duke.edu)
Note, in the case of an odd number of students, as in the example above, the last group should have three students.
For extra credit, you should output your list in HTML format as shown below (instead of plain text as above). Although the names and email address should be printed as above, the text should be tagged to produce something like the list below (click on "Source" in the "View" menu of your browser to see the tags used to create this list). In this case, the group numbers should be tagged as headings and the group members tagged as a bulleted list. Additionally, the email address should be tagged as a link to send email to the given address.
Group 1
- Arjun Menon (arjun.menon@duke.edu)
- Sandip Patel (sandip.patel@duke.edu)
Group 2
- Andrew Tupper (andrew.tupper@duke.edu)
- Karl Mischke (karl.mischke@duke.edu)
Group 3
- Jonathan Pollock (jonathan.pollock@duke.edu)
- Mariya Yevsyukova (yevsyuko@duke.edu)
Group 4
- Shao Tong (shao.tong@duke.edu)
- Ryan Rattet (ryan.rattet@duke.edu)
Group 5
- Edward Moulton (edward.moulton@duke.edu)
- Christopher Zeiders (christopher.zeiders@duke.edu)
Group 6
- Jason Robins (jason.robins@duke.edu)
- Jeffrey Stanley (jeff.stanley@duke.edu)
- Andrew Van Kirk (andrew.vankirk@duke.edu)
![]()