Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to add to my C++ code I pasted below where it will check a HTML source file (et.html) from the screenshot below where

I need to add to my C++ code I pasted below where it will check a HTML source file (et.html) from the screenshot below where it will compare each tag with it matching tag such as

and , where it will print "legal" or illegal" as the result. I need to include all the matching tags that are featured in the sample html source file from the screenshot below in my program.

image text in transcribed

#include

#define MAX 1000

using namespace std;

class Stack{

int top;

public:

int a[MAX]; // Max size of Stack

Stack(){

top = -1;

}

//top is initialized to -1 to check the emptiness of the stack

bool push(int x);

int pop();

bool isEmpty();

int peek();

};

int Stack::peek(){

return a[top];

}

bool Stack::push(int x){

if (top >= MAX){

cout

return false;

}

else{

a[++top] = x;

return true;

}

}

int Stack::pop(){

if (top

return 0;

else{

int x = a[top--];

return x;

}

}

//Checks the stack if its empty or not

bool Stack::isEmpty(){

return (top

}

// checks for pairs

bool Pair(char opening,char closing){

if(opening == '(' && closing == ')') return true;

else if(opening == '{' && closing == '}') return true;

else if(opening == '[' && closing == ']') return true;

return false;

}

bool Balanced(string exp){

Stack S;

for(int i =0;i

if(exp[i] == '(' || exp[i] == '{' || exp[i] == '[')

S.push(exp[i]);

else if(exp[i] == ')' || exp[i] == '}' || exp[i] == ']'){

if(S.isEmpty() || !Pair(S.peek(),exp[i]))

return false;

else

S.pop();

}

}

return S.isEmpty() ? true:false;

}

int main(){

string expression; // input expression

ifstream in("program.c");

if(in.is_open()) {

expression = "";

string line;

while(getline(in, line)) {

expression += line+" ";

}

}

else {

cout

return 0;

}

// check expression

if (Balanced(expression))

cout

else

cout

return 0;

}

Description: Make use of your own stack implementation (from Lab Practice 5) to check any HTML source file for balanced tags Hint: For a legal HTML source file, each should pair with a matching , for example, and . Below is a sample HTML source file

ET Department

The Engineering Technology Department is one of six academic departments in the College of Engineering at The University of Toledo. The Department offers ABET-accredited professional technical programs leading to the Bachelor of Science degree in four areas of study.

  • Computer Science and Engineering Technology (CSET)/li>
  • Construction Engineering Technology (CET)
  • Electrical Engineering Technology (EET)
  • Mechanical Engineering Technology (MET)1i> Write your program using C++, it reads the string of symbols from a HTML source file (for example, et,html) and print'.legal" orillegal" as the result Description: Make use of your own stack implementation (from Lab Practice 5) to check any HTML source file for balanced tags Hint: For a legal HTML source file, each should pair with a matching , for example, and . Below is a sample HTML source file

    ET Department

    The Engineering Technology Department is one of six academic departments in the College of Engineering at The University of Toledo. The Department offers ABET-accredited professional technical programs leading to the Bachelor of Science degree in four areas of study.

  • Computer Science and Engineering Technology (CSET)/li>
  • Construction Engineering Technology (CET)
  • Electrical Engineering Technology (EET)
  • Mechanical Engineering Technology (MET)1i> Write your program using C++, it reads the string of symbols from a HTML source file (for example, et,html) and print'.legal" orillegal" as the result
  • Step by Step Solution

    There are 3 Steps involved in it

    Step: 1

    blur-text-image

    Get Instant Access to Expert-Tailored Solutions

    See step-by-step solutions with expert insights and AI powered tools for academic success

    Step: 2

    blur-text-image

    Step: 3

    blur-text-image

    Ace Your Homework with AI

    Get the answers you need in no time with our AI-driven, step-by-step assistance

    Get Started

    Recommended Textbook for

    Big Data 29th British National Conference On Databases Bncod 2013 Oxford Uk July 2013 Proceedings Lncs 7968

    Authors: Dan Olteanu ,Georg Gottlob ,Christian Schallhart

    2013th Edition

    3642394663, 978-3642394669

    More Books

    Students also viewed these Databases questions

    Question

    Prepare an ID card of the continent Antarctica?

    Answered: 1 week ago

    Question

    What do you understand by Mendeleev's periodic table

    Answered: 1 week ago

    Question

    How autonomous should the target be left after the merger deal?

    Answered: 1 week ago