Question: Here's the coding that need to be fixed : #include #include #include #include using namespace std; int adminView(); int studentView(); int studentLogin(); int checkCredentials(string userName,

Here's the coding that need to be fixed :
#include
#include
#include
#include
using namespace std;
int adminView();
int studentView();
int studentLogin();
int checkCredentials(string userName, string password);
int deleteAllStudents();
int checkListOfStudentsRegistered();
int getListOfStudentsWithTheirPresenseCount();
int registerStudent();
int adminLogin();
int registerStudent();
int markMyAttendance(string username);
int countMyAttendance(string username);
int adminView()
{
int goBack = 0;
while(1)
{
system("cls");
cout
cout
cout
cout
cout
int choice;
cout
cin>>choice;
switch(choice)
{
case 1: registerStudent();break;
case 2: deleteAllStudents(); break;
case 3: checkListOfStudentsRegistered(); break;
case 4: getListOfStudentsWithTheirPresenseCount(); break;
case 0: goBack = 1;break;
default: cout
getchar();
}
if(goBack == 1)
{
break; //break the loop
}
}
return 0;
}
int studentLogin()
{
system("cls");
cout
studentView();
return 0;
}
int adminLogin()
{
system("cls");
cout
string username;
string password;
cout
cin>>username;
cout
cin>>password;
if(username=="admin" && password=="admin@2")
{
adminView();
getchar();
}
else
{
cout
cout
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
while(getline(read, line)) {
if(line == temp)
{
recordFound = 1;
break;
}
}
if(recordFound == 0)
return 0;
else
return 1;
}
else
{
return 0;
}
}
int getAllStudentsbyName()
{
cout
cout
getchar();getchar();
return 0;
}
int studentView()
{
int res;
cout
string username, password;
cout
cin>>username;
cout
cin>>password;
res = checkStudentCredentials(username, password);
if(res == 0)
{
cout
cout
getchar(); getchar();
return 0;
}
int goBack = 0;
while(1)
{
system("cls");
cout
cout
cout
int choice;
cout
cin>>choice;
switch(choice)
{
case 1: markMyAttendance(username); break;
case 2: countMyAttendance(username); break;
case 0: goBack = 1;break;
default: cout
getchar();
}
if(goBack == 1)
{
break; //break the loop
}
}
}
int markMyAttendance(string username)
{
cout
cout
//to do: implement this functionality
getchar();getchar();
return 0;
}
int countMyAttendance(string username)
{
cout
cout
//todo: implment this functionality
getchar();getchar();
return 0;
}
int deleteAllStudents()
{
cout
cout
//todo: implement this functionality
getchar(); getchar();
return 0;
}
int checkListOfStudentRegistered()
{
cout
cout
//todo: implment this functionality
getchar(); getchar();
return 0;
}
int getListOfStudentsWithTheirPresenseCount()
{
cout
cout
//todo: implement this functionality
getchar(); getchar();
return 0;
}
int checkListOfStudentsRegistered(){
cout
//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
}
read.close();
}
else
{
cout
}
cout
getchar(); getchar();
return 0;
}
int registerStudent()
{
cout
string name, username, password, address;
getchar();
char n[50];
cout
cout>username;
cout>password;
getchar();
char add[100];
cout
//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
getchar(); getchar();
read.close();
return 0;
}
}
read.close();
ofstream out;
out.open("db.dat", ios::app);
out
out.close();
ofstream out1;
string temp = username+".dat";
out1.open(temp.c_str());
out1
out1
out1
out1
out1.close();
cout
cout
getchar(); getchar();
return 0;
}
int main(int argc, char** argv) {
while(1)
{
system("cls");
cout
cout
cout
cout
cout
int choice;
cout
cin>>choice;
switch(choice)
{
case 1: studentLogin(); break;
case 2: adminLogin(); break;
case 0:
while(1)
{
system("cls");
cout
char ex;
cin>>ex;
if(ex == 'y' || ex == 'Y')
exit(0);
else if(ex == 'n' || ex == 'N')
{
break;
}
else{
cout
getchar();
}
}
break;
default: cout
getchar();
}
}
return 0;
}
I am doing programming project about students attendance management and I am facing some issues doing the coding. Some functions are not functioning as I wanted. Hope you can help to fix my coding. Admin login Username: admin Password: admin@2 Students login part issues : 1)'invalid credential' keep appearing eventhough the username and password entered are correct. Admin login part issues : 1)'delete all students name registered' function in 'admin login' is not functioning. Means the list of names still exist. 2)'Get list of students with their attendance count' function in 'admin login' not functioning. Students attendance couldn't be taken. 3)'Register username' function. In admin login part the usernames listed in 'checklist of students registered by username' are strange, means the last letter of username according to the last letter of the previous username
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
