Question

In: Computer Science

Create a C++ or Java program codes for Login Attendance applying the queue principle that will...

Create a C++ or Java program codes for Login Attendance applying the queue principle that will select students from the last attendance login to answer a question.

NOTE: Program execution should include deletion and insertion of attendance information/element

Solutions

Expert Solution

C++ Project on Attendance Management

Features

  • This project manages attendance of students
  • Admin can register students and create username & password for student
  • Student can login, mark attendance of same day & also can see history of attendance
  • Please note Admin username is : "admin" , password is "admin@2"
  • Compiled on g++ compiler

Source Code

#include <iostream> #include <string> #include <fstream> #include <cstring> using namespace std; int adminView(); int studentView(); int studentLogin(); int checkCredentials(string userName, string password); int getAllStudentsbyRollNo(); int deleteAllStudents(); int deleteStudentbyRollno(); int checkListOfStudentsRegistered(); int checkPresenseCountbyRollno(); int getListOfStudentsWithTheirPresenseCount(); int registerStudent(); int adminLogin(); int registerStudent(); int markMyAttendance(string username); int countMyAttendance(string username); int delay(); int delay() { for(int i = 0; i<3; i ++) { cout<<"\n Saving Records ..."; for(int ii = 0; ii<20000; ii ++) { for(int iii = 0; iii<20000; iii ++) { } } } cout<<"\n Exiting Now ..."; for(int i = 0; i<3; i ++){ for(int ii = 0; ii<20000; ii ++) { for(int iii = 0; iii<20000; iii ++){ } } } return 0; } int adminView() { int goBack = 0; while(1) { system("cls"); cout<<"\n 1 Register a Student"; cout<<"\n 2 Delete All students name registered"; cout<<"\n 3 Delete student by rollno"; cout<<"\n 4 Check List of Student registered by userame"; cout<<"\n 5 Check presense count of any student by Roll No"; cout<<"\n 6 Get List of student with their attendance count"; cout<<"\n 0. Go Back <- \n"; int choice; cout<<"\n Enter you choice: "; cin>>choice; switch(choice) { case 1: registerStudent();break; case 2: deleteAllStudents(); break; case 3: deleteStudentbyRollno(); break; case 4: checkListOfStudentsRegistered(); break; case 5: checkPresenseCountbyRollno(); break; case 6: getListOfStudentsWithTheirPresenseCount(); break; case 0: goBack = 1;break; default: cout<<"\n Invalid choice. Enter again "; getchar(); } if(goBack == 1) { break; //break the loop } } return 0; } int studentLogin() { system("cls"); cout<<"\n -------- Student Login ---------"; studentView(); delay(); return 0; } int adminLogin() { system("cls"); cout<<"\n --------- Admin Login --------"; string username; string password; cout<<"\n Enter username : "; cin>>username; cout<<"\n Enter password : "; cin>>password; if(username=="admin" && password=="admin@2") { adminView(); getchar(); delay(); } else { cout<<"\n Error ! Invalid Credintials.."; cout<<"\n Press any key for main menu "; getchar();getchar(); } return 0; } int checkStudentCredentials(string username, string password) { // read file line by line & check if username-password.dat exist? // if it exsist return 1 else 0 ifstream read; read.open("db.dat"); if (read) { // The file exists, and is open for input int recordFound = 0; string line; string temp = username + password + ".dat"; cout<<"\n file name is : "<<temp; while(getline(read, line)) { if(line == temp) { recordFound = 1; break; } } if(recordFound == 0) return 0; else return 1; } else { return 0; } }

int getAllStudentsbyName()
{
cout<<"\n List of All Students by their Name \n"; 

cout<<"\n Please any key to continue..";
getchar();getchar();

return 0;
}

int getAllStudentsbyRollNo()
{
cout<<"\n List of All Students by their Roll No \n";

cout<<"\n Please any key to continue..";
getchar();getchar();

return 0;               
        
}

int deleteStudentbyRollno()
{
        
cout<<"\n Delete any Student by their Roll No \n";                

cout<<"\n Please any key to continue..";
getchar();getchar();

return 0;
}


int checkPresenseCountbyRollno()
{
cout<<"\n Check presense count of any Student by Roll No \n";     

cout<<"\n Please any key to continue.."   ;
getchar();getchar();

return 0;       
}

int checkAllPresenseCountbyRollno()
{
cout<<"\n Check presense count of All Students by Roll No & Name \n";             
cout<<"\n Please any key to continue.."   ;
getchar();getchar();

return 0;
}

int studentView()
{
cout<<"\n ------- Student Login-------- \n";              

string username, password;

cout<<"\n Enter username : ";
cin>>username;

cout<<"\n Enter password : ";
cin>>password;

int res = checkStudentCredentials(username, password);

if(res  == 0)
{
   cout<<"\n Invalid Credentials !!";
   cout<<"\n Press any key for Main Menu..";
   getchar(); getchar();        
   return 0;
} 

int goBack = 0;
while(1)
{
system("cls");

cout<<"\n 1 Mark Attendance fo Today ";
cout<<"\n 2 Count my Attendance";
cout<<"\n 0. Go Back <- \n";
int choice;

cout<<"\n Enter you choice: ";
cin>>choice;

switch(choice)
{
        case 1: markMyAttendance(username); break;
        case 2: countMyAttendance(username); break;
        case 0: goBack = 1;break;
    default: cout<<"\n Invalid choice. Enter again ";
    getchar();                  
}   

if(goBack == 1)
{
break; //break the loop
}     
        
}
   
}

int markMyAttendance(string username)
{
cout<<"\n Mark Attendance for today !!";  
cout<<"\n Please any key to continue..";
//todo: implement this functionality

getchar();getchar();

return 0;       
} 

int countMyAttendance(string username)
{
cout<<"\n Count my attendace for today !!";       
cout<<"\n Please any key to continue..";
//todo: implment this functionality

getchar();getchar();

return 0;       
} 

int deleteAllStudents()
{
cout<<"\n In delete all students !!";
cout<<"\n Please any key to continue..";
//todo: implement this functionality

getchar(); getchar();
return 0;
}


int checkListOfStudentRegistered()
{
cout<<"\n List of All registered registered !!";
cout<<"\n Please any key to continue..";

//todo: implment this functionality

getchar(); getchar();
return 0;
}

int getListOfStudentsWithTheirPresenseCount()
{
cout<<"\n All Students with their Presense count !!";
cout<<"\n Please any key to continue..";
//todo: implement this functionality

getchar(); getchar();
return 0;
}

int checkListOfStudentsRegistered(){
cout<<"\n - Check List of Student Registered by Username-- ";     

//check if record already exist..
ifstream read;
read.open("db.dat");

if(read)
{   int recordFound =0; 
    string line;
    while(getline(read, line)) {
        char name[100];
        strcpy(name, line.c_str());
        char onlyname[100];
        strncpy(onlyname, name, (strlen(name) - 4));
        cout<<" \n " << onlyname;
    }
     read.close();        
}
else
{
cout<<"\n No Record found :(";
}
        
        
cout<<"\n Please any key to continue..";
getchar(); getchar();
return 0;
}


int registerStudent()
{
    cout<<"\n ----- Form to Register Student ---- \n";    

    string name, username, password, rollno, address, father, mother;
    
    cout<<"\n Enter Name : ";     cin>>name;
    cout<<"\n Enter Username : ";     cin>>username;
    cout<<"\n Enter password : ";     cin>>password;
    cout<<"\n Enter rollno : ";     cin>>rollno;
    getchar();
    
    char add[100];
    cout<<"\n Enter address : ";     cin.getline(add, 100);
    cout<<"\n Enter father : ";     cin>>father;
    cout<<"\n Enter mother : ";     cin>>mother;
    
    //check if record already exist..
    ifstream read;
    read.open("db.dat");
    
    if(read)
    {   int recordFound =0; 
           string line;
            while(getline(read, line)) {
        if(line == username+".dat" )
        {
                recordFound = 1 ;
            break;
                }
        }
        if(recordFound == 1)
        {
        cout<<"\n Username already Register. Please choose another username ";
        getchar(); getchar();
        delay();
        read.close();
        return 0;
                }
        }
    read.close();

    ofstream out;
        out.open("db.dat", ios::app);
        out<<username+".dat"<<"\n";
        out.close();

        ofstream out1;
        string temp = username+".dat";
        out1.open(temp.c_str());
        out1<<name<<"\n";   out1<<username<<"\n";       out1<<password<<"\n";
        out1<<rollno<<"\n";         out1<<add<<"\n";    out1<<father<<"\n";
        out1<<mother<<"\n";
        out1.close();

        cout<<"\n Student Registered Successfully !!";
    
    cout<<"\n Please any key to continue..";
        getchar(); getchar();
        return 0;               
}

Related Solutions

Create a C program that performs the following (please comment the codes): a) Create a Stack...
Create a C program that performs the following (please comment the codes): a) Create a Stack ADT. Stack should be implemented using the linked list. b) Enter 10 random integer numbers between 0 to 50 in the stack. c) After pushing each element, print the content of the top of the stack. c) Then pop out those 10 integer numbers and print those numbers. d) Finally destroy the Stack.
Need this in java .Create a simple login screen in java That lets people sign in...
Need this in java .Create a simple login screen in java That lets people sign in to the emergency room. It needs to ask for name, social,and DOB. Once all the information is received it then display the info back to them if any info is is missing have the program prompt the user to re enter their information.
Create a C++ login program using file for 2 user. Usernames must be in one file...
Create a C++ login program using file for 2 user. Usernames must be in one file and password in the other file. Ask user for their usernames and password if it matches, they logged in successfully. If it doesn’t match,they have 3 trials ,then they have to sign in and create a username and password. After creating a username and password, they have to go to the login page again. Must work for visual studio code
Write a C++ or Java application to create BOTH Stack & Queue data structures. The application...
Write a C++ or Java application to create BOTH Stack & Queue data structures. The application also creates a "DisplayStackElement" and "DisplayQueueElement" routine. The application must be menu driven (with an option to terminate the application) and provide the following features. Allow insertion of a "Circle" object/structure in the Stack data structures. The Circle contains a "radius" data member. The Circle also uses functions/methods "setRadius", "getRadius" and calculateArea (returns a double data type). Allow insertion of a "Circle" object/structure in...
C language Write a program in C to implement Queue and its operation (like create, insert,...
C language Write a program in C to implement Queue and its operation (like create, insert, delete, search) using array data structure.
Using the Queue ADT: Create a program that uses a Queue. Your program should ask the...
Using the Queue ADT: Create a program that uses a Queue. Your program should ask the user to input a few lines of text and then outputs strings in same order of entry. (use of the library ArrayDeque) In Java please.
C++ Language Create Login Register program without open .txt file simple program also if you can...
C++ Language Create Login Register program without open .txt file simple program also if you can hide password input option menu 1) Login 2) Register 3) exit
Program in Java Create a queue class to store integers and implement following methods: 1- void...
Program in Java Create a queue class to store integers and implement following methods: 1- void enqueue(int num): This method will add an integer to the queue (end of the queue). 2- int dequeue(): This method will return the first item in the queue (First In First Out). 3- void display(): This method will display all items in the queue (First item will be displayed first). 4- Boolean isEmpty(): This method will check the queue and if it is empty,...
create a program that will verify a user's login credentials. The program should prompt the user...
create a program that will verify a user's login credentials. The program should prompt the user to enter his/her username and password at the keyboard. Then it should read the data from a data file named "login.txt". The file "login.txt" will contain a list of 3 valid usernames and passwords to verify the login information supplied by a user.  If the username and password entered by the user matches one of the sets read from the file, the program should print...
DO IN C++ Secret Codes! Create a program that will accept a message from the user...
DO IN C++ Secret Codes! Create a program that will accept a message from the user and either encrypt ordecrypt it with the following algorithms: To encrypt: - get the character you wish to encrypt - find the index of that character in the alphabet array - add the shift offset to the index - add the increment to the index - "wrap around" the new index so the result is between 0 and 29 - find the character at...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT