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

Let us create an application that manages attendance for a course. This applicat

ID: 3678288 • Letter: L

Question

Let us create an application that manages attendance for a course. This application has four major requirements:

Requirement 1 (Import records): The application must import records pertaining to each student registered for the course from a course list.

Requirement 2 (Mark absences): The application must allow the user to mark each student in the course as present or absent on any given day.

Requirement 3 (Generate reports): The application must generate reports based on criteria.

Requirement 4 (Menu): The application must support a user interface to the attendance tracker.

Import records: Records must be read from a comma-separated values (.csv) course file. A .csv file stores data as plaintext in tabular form. Each row in the file is considered arecord. Each record consists of fields separated by commas. Please start with this .csv file. In this assignment the following fields will be present for each record:

record number (max 3 digits)

ID number (max 9 digits)

name (last, first)

email

units (number of credits for class or AU for audit)

program (major)

level (freshman, sophomore, junior, senior, graduate)

You are required to use a dynamic singly linked list to store student records. As each record is imported from the file, the record must be inserted at the front of the list. Inserting at the front of a dynamic linked list is very efficient (constant time). You are required to implement two classes for the list. One class is the node class, which stores the fields acquired from each record. In addition to the fields in the file, you are required to add two extra fields in your node. These fields include number of absences and an array for storing the dates of absences. The second class is the List class, which is a container for the nodes. The List class will be considered your master list.

Mark absences: The user of the program should be able to view the master list of students in the course and mark absences for the current day. This may be implemented by simply traversing the linked list (linear time) and asking is the student absent? Yes or no? The date for the day must be derived from the computer’s date. The following fragment of code illustrates how to derive the date from the computer:

       // retrieved from stackoverflow - http://stackoverflow.com/questions/997946/how-to-get-current-time-and-date-in-c

       time_t t = time(0);   // get time now

       struct tm * now = localtime( & t );

       cout << (now->tm_year + 1900) << '-'

            << (now->tm_mon + 1) << '-'

            << now->tm_mday

            << endl;

Generate reports: The user of the program should be able to generate three versions of reports. One version is a report that shows all of the students in the class and the number of times they have been absent, along with the corresponding dates they were absent. A second version is a report that provides only the students that have been absent greater than some threshold set by the user. A third version is a report that provides the students that were absent on a certain date. The reports only need to report the each student’s name, email, along with the absences information. Write each report to a different .txt file.

Menu: At startup of the program a menu must be displayed. The menu must provide six options. These include:

Import course list

Load master list

Store master list

Mark absences

BONUS: Edit absences

Generate report

Exit

Option 1: Reads the .csv course file and overwrites the master list.

Option 2: Populates the master list with previous nodes from master.txt.

Option 3: Stores the contents of the master list’s nodes to master.txt.

Option 4: Runs through the master list, displays each student’s name, and prompts if he/she was absent for the current day.

BONUS: Option 5: Prompts for an ID number or name of student to edit. Prompts for the date of absence to edit.

Option 6: Leads to submenu -> 1. Generate report for all students. 2. Generate report for students with absences that match or exceed (the number entered by the user). 3. Generate date report.

Option 7: Exit the program.

You are required to define a class for your menu.

BONUS: Edit absences - The user of the program should be able to access each student’s record and edit absences. A search (linear time) through the master list based on student ID or name must be supported. If a student was initially marked absent for a date, but later was determined to be present, then the absence should be removed from the record. This includes updating the number of absences field. Be sure to add an Edit option to your menu!

in C++

heres the csv file

ID Name Email Units Program Level 1 1111 Smith,John smithj@cpts122.edu 4 CS Freshman 2 8147 Beck,Sara sara@cpts122.edu 4 EE Junior 3 1121 Leinart,Timothy tim@cpts122.edu 4 EE Junior 4 4478 Art,Bruce bart@cpts122.edu AU CPTE Freshman 5 2121 James,Hannah jameshannah@cpts122.edu 4 CS Freshman 6 5530 Payton,Ella epayton@cpts122.edu 4 CPTE Graduate 7 7759 Sam,Theo samt@cpts122.edu 4 EE Sophomore 8 1122 Smith,Jane jane@cpts122.edu 4 CS Sophomore 9 1222 Willis,Bruce brucewillis@cpts122.edu AU CS Sophomore 10 3255 Mort,Kris mort@cpts122.edu 4 CS Senior

Explanation / Answer

#include <bits/stdc++.h>
using namespace std;

struct record{
   public:
       int record_num;
       int id;
       string first_name;
       string last_name;
       string email;
       string units;
       string program;
       string level;
       string in_class;
       record(int r,int i,string f,string l,string e,string u,string p,string l){
           record_num = r;
           id = i;
           first_name = f;
           last_name = l;
           email = e;
           units = u;
           program = p;
           level = l;
           in_class = "ATTENDANCE NOT TAKEN YET";
       }
};

int menu(){
   int n;
   cout << "1. import course list" << endl;
   cout << "2. store master list" < endl;
   cout << "3. Mark absences" << endl;
   cout << "4. Edit absences" << endl;
   cout << "5. Generate report" << endl;
   cout << "6. Exit" < endl;
   cout << "Your Choice : ";
   cin >> n;
   return n;
}

void print(record* r){
   cout << endl << endl;
   cout << "RECORD NUMBER : " << r->record_num << endl;
   cout << "ID : " << r->id << endl;
   cout << "FIRST NAME : " << r->first_name << endl;
   cout << "LAST NAME : " << r->last_name << endl;
   cout << "EMAIL : " << r->email << endl;
   cout << "PROGRAM : " << r->program << endl;
   cout << "UNITS : " << r->units << endl;
   cout << "LEVEL : " << r->level << endl;
   cout << "IN_CLASS : " << in_class << endl;
}

int main(){
   vector<record*> my_rec;
   bool attend = false;
   while (true){
       int n = menu();
       if (n == 1){
           ifstream infile;
           infile.exceptions ( std::ifstream::failbit | std::ifstream::badbit );
           try {
               infile.open("input.txt");
               string str,temp;
               vector<string> Token;
               while (!infile.eof()){
                   Token.clear();
                   getline(infile,str);
                   stringstream line(str);
                   while (line >> temp){
                       Token.push_back(temp);
                   }
                   record *r = new record(atoi(Token[0].c_str()),atoi(Token[1].c_str()),Token[3],Token[2],Token[4],Token[5],Token[6],Token[7]);
                   my_rec.push_back(r);
               }
               infile.close();
           }
           catch (std::ifstream::failure e) {
               std::cerr << "The File ---- input.csv ---- is not Here ";
           }
       }
       else if (n == 2){
           ofstream outfile;
           outfile.open("input.csv");
           for (int i = 0; i < my_rec.size(); i++){
               outfile << my_rec[i]->record_num << "," << my_rec[i]->id << "," << my_rec[i]->last_name << "," << my_rec[i]->first_name << "," << my_rec[i]->email << "," << my_rec[i]->units << "," << my_rec[i]->program << "," << my_rec[i]->level << endl;
           }
       }
       else if (n == 3){
           attend = true;
           for (int i = 0; i < my_rec.size(); i++){
               char ch;
               cout << "IS " << my_rec[i]->first_name << " " << my_rec[i]->last_name << " IS PRESENT (P or p) or ABSENT (A or a) ? ";
               cin >> ch;
               if (ch == 'P' || ch == 'p')
                   my_rec[i]->in_class = "PRESENT";
               else
                   my_rec[i]->in_class = "ABSENT";  
           }
       }
       else if (n == 4){
           if (attend == false)
               cout << "ATTENDANCE NOT TAKEN YET" << endl << endl;
           else{
               int id;
               char ch;
               cout << "Enter the ID for which you want to edit the attendance : ";
               cin >> id;
               cout << "ENTER (P or p for PRESENT; A or a for ABSENT) : ";
               cin >> ch;
               for (int i = 0; i < my_rec.size(); i++){
                   if (my_rec[i]->id == id){
                       if (ch == 'P' || ch == 'p')
                           my_rec[i]->in_class = "PRESENT";
                       else
                           my_rec[i]->in_class = "ABSENT";
                       break;
                   }
               }
           }
          
       }  
       else if (n == 5){
           int id;
           cout << "Enter the ID for which you want the report : ";
           cin >> id;
           for (int i = 0; i < my_rec.size(); i++){
               if (my_rec[i]->id == id){
                   print(my_rec[i]);
                   break;
               }
           }
       }
       else
           break;
   }
   return 0;
}