Studentmark.H #Ifndef #Define Class Private Class Public Int Double Char
Studentmark.H #Ifndef #Define Class Private Class Public Int Double Char
#ifndef STUDENTMARK_H
#define STUDENTMARK_H
class StudentMark
{
private:
class Node
{
public:
int StuMatric;
double StuMark;
char StuName[200];
Node*link;
};
Node*pHead;
Node*pCurr;
Node*pPrev;
int numItem;
public:
StudentMark();
~StudentMark();
void AddToFront();
void DeleteFront();
void DeleteMiddle();
bool Traverse(int , int &);
void AddToMiddle();
void printData();
int NumberOfItem();
};
#endif
Main.cpp
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <string>
#include <conio.h>
#include <windows.h>
using namespace std;
#include "StudentMark.h"
int main()
{
cout << "Enter you password: (max 25 characters)" << endl;
// password (char array, doesn't work as string)
char password[25];
// now fill the rest of the array with '\0' (NULL) character
for (i; i < strlen(password); i++)
password[i] = '\0';
int choice;
int target;
int location;
StudentMark systems;
cout << " %*%*%*%*%*% Welcome to StudentMark System %*%*%*%*%"
<<endl;
cout << " %& 1- Insert Student Name %&"
<<endl;
cout << " %& 2- Check Inserted Student Name %&"
<<endl;
cout << " %& 3- Find Inserted Student Name %&"
<<endl;
cout << " %& 4- Delete unwanted Student Name %&"
<<endl;
cout << " %*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%"
<<endl<<endl;
cout << "Please Enter Your Choice : " ;
cin>>choice;
do
{
switch(choice)
{
case 1 :
systems("cls");
systems.AddToMiddle();
if (systems.NumberOfItem() == 0)
{
systems.AddToFront();
}
else
{
cout<<"1 student name added!!";
}
getch();
break;
case 2 :
systems("cls");
systems.printData();
getch();
break;
case 3:
system("cls");
systems.printData();
getch();
break;
case 4:
systems("cls");
case 5:
return 0;
}
systems("cls");
cout << " %*%*%*%*%*% Welcome to StudentMark System %*%*%*%*%" <<endl;
cout << " %& 1- Insert Student Name %&" <<endl;
cout << " %& 2- Check Inserted Student Name %&" <<endl;
cout << " %& 3- Find Inserted Student Name %&" <<endl;
cout << " %& 4- Delete unwanted Student Name %&" <<endl;
cout << " %& 5- Thanks For Using Our System %&" <<endl;
cout << " %*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%*%"
<<endl<<endl;
cout << "Please Enter Your Choice : " ;
cin>>choice;
}
while (choice!=5);
return 0;
}
Student.cpp
#include <iostream>
#include<string.h>
using namespace std;
#include "StudentMark.h"
StudentMark::StudentMark()
{
numItem=0;
pHead=0;
}
StudentMark::~StudentMark()
{
}
void StudentMark::AddToMiddle()
{
int StuMatric;
double StuMark;
char Name[200];
Node *pNew=new Node;
cout<<"Please Insert Student Name : ";
cin>>Name;
cout<<"Please Insert Student Mark : ";
cin>>StuMark;
cout<<"Please Insert Student Matric : ";
cin>>StuMatric;
if (numItem==1)
pCurr=pHead;
pNew->StuMatric = StuMatric;
pNew->StuMark = StuMark;
strcpy(pNew->StuName,Name);
pNew->link = pCurr->link;
pCurr->link = pNew;
pCurr = pNew;
numItem++;
}
void StudentMark::AddToFront()
{
int StuMatric;
double StuMark;
char Name[200];
Node *pNew=new Node;
cout<<"The code must between 1-20 and there are no space for
title."<<endl;
cout<<"Please Insert Student Name : ";
cin>>Name;
cout<<"Please Insert Student Mark : ";
cin>>StuMark;
cout<<"Please Insert Student Matric : ";
cin>>StuMatric;
pNew->StuMatric = StuMatric;
pNew->StuMark = StuMark;
strcpy(pNew->StuName,Name);
pNew->link=pHead;
pHead=pNew;
numItem++;
void StudentMark::printData()
{
if (pHead==0)
cout<<"There Are No Any Student Name";
else
{
pCurr=pHead;
while (pCurr != 0)
{
cout<<endl;
cout<<"Student Matric : ";
cout<<pCurr->StuMatric<<" ";
cout<<endl;
cout<<"Student Name : ";
cout<<pCurr->StuName<<" ";
cout<<endl;
cout<<"Student Mark : RM ";
cout<<pCurr->StuMark<<" ";
cout<<endl<<endl;
pCurr=pCurr->link;
}
cout<<"\n";
}
}
void StudentMark::DeleteFront()
{
pHead=pHead->link;
numItem--;
cout<<"Your Request Is Successful."<<endl;
}
void StudentMark::DeleteMiddle()
{
pPrev->link = pCurr->link;
numItem--;
cout<<"Your Request Is Successful."<<endl;
}
int StudentMark::NumberOfItem()
{
return numItem;