Write a program that checks whether or not a given file

Assignment Help Computer Engineering
Reference no: EM132131872

Simple XML Checker!

Objective:

Write a program that checks whether or not a given file is formatted correctly for a very simple version of XML. In this simple version of XML you have tags that denote information.

Each tag has a "start-tag", and an "end-tag". The start-tag is denoted by a value enclosed by "< >", and the end-tag similarly denoted by "".

Each start-tag must have an end-tag. Elements fall in between the start and end tags, and can also other tags can be nested in as well.

In this version of XML you can assume that tags and elements will always be on separate lines, and no additional attributes (such as id = "3">) will be a part.

Well formatted example

33

Another well formatted example

100

Not well formatted example

44

Another not well formatted example

33

To solve this problem you must:

Write a stack, and use it to solve this problem

You may NOT use the built-in java stack

You may either implement the stack as a linked structure or an array. If you use an array assume the max size is 100;

Write another class that has a main method which takes in a file name and checks whether or not that file is correctly formatted.

Here's a basic idea:

If the next line is enclosed by "< >" with a tag in between, then push the tag onto the stack

If the next line is enclosed by "" with a tag in between, then

Pop one element off the stack

Check if that element matches with end-tag. If it does then continue on, but if it doesn't then it is not formatted correctly

All other values and elements can be ignored

If by the end there are no tags left on the stack then it is properly formatted, but if the stack still has tags then it is not properly formatted.

Also the string methods "charAt(index)" and "substring(startIndex, endIndex)" may be very useful

Here are some files to test with

goodXML1

goodXML2

goodXML3

badXML1

badXML2

badXML3

Reference no: EM132131872

Questions Cloud

Will you want an int or float or double : Last step is to ask the user if they want to continue doing another operation. Ask them to press a ‘y' for yes and ‘n' for no.
Molecular equation for precipitation reaction : Consider the other product and its phase, and then write the balanced molecular equation for this precipitation reaction.
Write a program that supports the given operations : Write a program that supports the following operations: int add(string login, string time, int priority, int size, int handle).
Calculate the standard deviation value of precipitate weight : Q1: Calculate the standard deviation of chloride concentration of your measurement result Q2: Calculate the relative standard deviation (RSD) of your chloride
Write a program that checks whether or not a given file : Write a program that checks whether or not a given file is formatted correctly for a very simple version of XML.
Aqueous solution containing an unknown monoprotic acid : Suppose 100.0 mL of an aqueous solution containing an unknown monoprotic acid (called HA) is titrated with 0.150 M KOH.
Write a program that encrypts a character from the list : Write a companion program to decrypt the values you encrypt with the given program.
What rules would you apply to clean the data : Identify what rules would you apply for ensuring the data is clean and is of high quality.
Ground beef relative of broiled chicken : A 41 kg person walking 5.6 km/hr requires 758 kJ of energy per hour. How much further does he have to walk to consume the addition

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd