in c or c please help me Formal Methods Project 1 Due Date S


in c++ or c#

please help me

Formal Methods Project 1. Due Date Sunday: 23 October 2016. Building Simple DFA. You are required to build a simple DFA Your DFA must be able to recognize a password with the following characteristics. 1- The length of the password ranges between6 and symbols. 2- The password must contain at least one digit, and must end with a special character a, or &) The alphabet of the DFA consists of English characters, digits 0 9 and special characters & In order to build the DFA, you must first initialize your transitions based on your own selected password. You can use a 2-dimensional array for this purpose).. Then your DFA must recognize only the password you specified inthe initialization part of the program. Your DFA will be tested with different passwords. It must reject all wrong passwords, including the ones used with Wrong alphabet.. RULES for the PROJECT. 2- Every student must use his/own password, which must be different from others. 3- If two passwords are similar, both programs will be counted as forgery and will be counted as ZERO GOOD LUCK

Solution

#include <iostream.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
struct Node //Structure to represent a Node or Vertices of a Graph
{
char data[10];
struct Node *next,*head; //Pointers to next node and Start
struct Adjacent *adj; //Pointer to Adjacent node
};
struct Adjacent //Structure to represent Adjacent node of a Graph
{
char data;
struct Node *next;
struct Adjacent *adj; //Pointer for next Adjacent
};
Node *New,*top; //Global Variables for New node and Pointer to Top
void create()
{
New = new Node; //Create a node
New -> next = NULL;
New -> adj = NULL;
}
void CreateVertices(Node *&n,char *Item) //Function to Create a Vertices of a Graph
{
if(n == NULL) //if first node
{
n = new Node; //Create a node
strcpy(n -> data,Item); //Insert Data
n -> next = NULL;
n -> adj = NULL;
n -> head = n; //Initialize head
top = n; //Update top
return;
}
create(); //Create a node
strcpy(New -> data,Item); //Insert Item
top -> next = New; //Assign new node to next of top
top = New; //Update top
}
void LinkVertices(Node *&n)
{
Adjacent *a,*ptr;
int inputSize;
char *inputString;
cout << \"\ How many inputs? \";
cin >> inputSize;
inputString = new char[inputSize];
cout << \"\ Enter Input Alphabets : \";
for(int j = 0;j < inputSize;j++)
cin >> inputString[j];
Node *temp = n -> head;
while(temp != NULL) //Until last
{
int flag = 0,i = 0;
char ch[10];
do
{
cout << \"\ Enter Transition (\" << temp -> data << \", \" << inputString[i] << \") : \";
cin >> ch; //Scan Adjacent
a = new Adjacent; //Create an Adjacent
a -> data = inputString[i++]; //Insert Data
a -> adj = NULL;
a -> next = NULL;
if(flag == 0) //if first Adjacent
{
temp -> adj = a;
ptr = a;
flag++; //Increase flag
}
else
{
ptr -> adj = a;
ptr = a;
}
Node *tmp = n -> head;
while(tmp != NULL)
{
if(strcmpi(tmp -> data,ch) == 0)
a -> next = tmp;
tmp = tmp -> next;
}
}while(i < inputSize);
temp = temp -> next;
}
}
char* CurrentState(Node *n,char *state, char input)
{
Node *temp = n -> head, *tmp;
Adjacent *a;
char nextState[10] = \"\";
while(temp != NULL)
{
if (strcmpi(temp -> data,state) == 0)
{
a = temp -> adj;
while(a != NULL)
{
if (a -> data == input)
{
tmp = a -> next;
strcpy(nextState,tmp -> data);
return nextState;
}
a = a -> adj;
}
}
temp = temp -> next;
}
return nextState;
}
char* Transition(Node *n,char *state, char *inputString)
{
int len = strlen(inputString);
int i = 0;
char chrTemp;
while(i < len)
{
chrTemp = inputString[i++];
strcpy(state,CurrentState(n,state,chrTemp));
if (i != len)
{
chrTemp = inputString[i++];
strcpy(state,CurrentState(n,state,chrTemp));
}
}
return state;
}
void display(Node *n)
{
if(n == NULL)
{
cout << \"Nothing to Display.\";
return;
}
Node *temp = n, *tmp;
Adjacent *a;
while(temp != NULL) //Until Last
{
cout << temp -> data << \' \'; //Print first data
a = temp -> adj; //go to adjacent node
while(a != NULL) //Until last of adjacent
{
tmp = a -> next;
cout << tmp -> data << \' \'; //print adjacent
a = a -> adj; //goto next adjacent
}
cout << endl;
temp = temp -> next; //goto next Node
}
}
int main()
{
int m;
char startState[10],finalState[10];
Node *nd = NULL;
cout << \"How Many States? \"; //Number of Nodes on a Graph
cin >> m;
cout << \"\ State(s) Name : \"; //Input the name of Vertices
for(int i = 0;i < m;i++)
{
char strBuf[15],strTemp[10];
strcpy(strBuf,\"Q\");
itoa(i,strTemp,10);
strcat(strBuf, strTemp);
strcat(strBuf, \"\\0\");
if (i == 0)
strcpy(startState,strBuf);
CreateVertices(nd,strBuf);
cout << strBuf << \" \";
}
cout << \"\ \ Enter Final State : \";
cin >> finalState;
LinkVertices(nd);
cout << \"\ The Transition Table is\ \";
cout << \"-----------------------\ \";
display(nd);
cout << endl;
char inputString[50];
cout << endl << \"Enter a String : \";
cin >> inputString;
char State[10];
strcpy(State,Transition(nd,startState,inputString));
if (strcmpi(State,finalState) == 0)
cout << \"\ String Accepted\";
else
cout << \"\ Invalid String\";
getch();
return 0;
}

 in c++ or c# please help me Formal Methods Project 1. Due Date Sunday: 23 October 2016. Building Simple DFA. You are required to build a simple DFA Your DFA mu
 in c++ or c# please help me Formal Methods Project 1. Due Date Sunday: 23 October 2016. Building Simple DFA. You are required to build a simple DFA Your DFA mu
 in c++ or c# please help me Formal Methods Project 1. Due Date Sunday: 23 October 2016. Building Simple DFA. You are required to build a simple DFA Your DFA mu
 in c++ or c# please help me Formal Methods Project 1. Due Date Sunday: 23 October 2016. Building Simple DFA. You are required to build a simple DFA Your DFA mu

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site