use java
Write an implementation to determine whether a given string is a well-formed HTML string. Your implementation should have the following classes and methods:
public class WellFormedHtmlChecker {
public boolean isWellFormed(String html) {
}
}
Please note the method isWellFormed is a non-static method.
Here the code is
import java.util.*;
public class WellFormedHtmlChecker{
public boolean isWellFormed(String array1){
Boolean tag = false;
String str = "";
String get = "";
Boolean goneTo = false;
Boolean isVisitedOnce = false;
List<String> htmlTags = new ArrayList<String>();
String array = array1;
for(int i = 0; i < array.length(); i++)
{
if(array.charAt(i) == '<')
{
if(!tag)
tag = true;
else{
return false;
}
}
else if(array.charAt(i) == '>'){
if(tag){
tag = false;
if(goneTo){
if(htmlTags.get(htmlTags.size() - 1).equals(str)){
htmlTags.remove(get);
goneTo = false;
}
else{
return false;
}
}
else
htmlTags.add(str);
str = "";
}
else{
return false;
}
}
else{
if(array.charAt(i) == '/'){
isVisitedOnce = true;
get = htmlTags.get(htmlTags.size() - 1);
goneTo = true;
}
else{
if(tag)
str += array.charAt(i);
}
}
}
if(!tag && !goneTo && isVisitedOnce)
return true;
else
return false;
}
public static void main(String []args){
Boolean out = new
WellFormedHtmlChecker().isWellFormed("<html><div><p>Checkcorrect</p></div></html>");//Give
your input html too
if(out) System.out.println("Correct HTML String");
else System.out.println("Incorrect HTML String");
}
}
Hope it helps , Thank you :)
use java Write an implementation to determine whether a given string is a well-formed HTML string....
IN JAVA. Implement a method, public static boolean isPalindrome(String) to determine whether the specified String is a palindrome or not. A palindrome is a phrase that reads the same forwardand backward; not including punctuation, spaces, or letter case. Some example palindromes include: Just the method please..
Java:
Create the skeleton.
Create a new file called ‘BasicJava4.java’
Create a class in the file with the appropriate name.
public class BasicJava4 {
Add four methods to the class that return a default value.
public static boolean isAlphabetic(char aChar)
public static int round(double num)
public static boolean useSameChars(String str1, String
str2)
public static int reverse(int num)
Implement the methods.
public static boolean isAlphabetic(char aChar):
Returns true if the argument is an alphabetic character, return
false otherwise. Do NOT use...
Write a JAVA contains method for a linked implementation of a sorted list. #This method is written from the implementation perspective, meaning it would go inside of the LinkedSortedList class. This means we have access to firstNode and numberOfEntries. #write an efficient solution. This will involve directly accessing the linked structure rather than only invoking existing methods. You can assume T is Comparable. #The method header is: public boolean contains(T anEntry)
A java program for this question please! Recursion: A word is considered elfish if it contains the letters: e, l, and f in it, in any order. For example, we would say that the following words are elfish: whiteleaf, tasteful, unfriendly, and waffles, because they each contain those letters. Write a recursive method called elfish(), that, given a word, tells us whether or not that word is elfish. The signature of the method should be: public static boolean elfish(String word)...
Please use Java. Write a non-recursive method that uses a stack to check whether its string parameter is a palindrome. Write a program to test and demo your method. Fibonacci Numbers Write a method that uses a stack to determine the desired Fibonacci number. Write a program to test and demo your method. Balancing Grouping Symbols Write a method that takes a string parameter and determines whether the string contains matching grouping symbols. Grouping symbols are parenthesis ( ), curly...
JAVA Write a program which will read a text file into an ArrayList of Strings. Note that the given data file (i.e., “sortedStrings.txt”) contains the words already sorted for your convenience. • Read a search key word (i.e., string) from the keyboard and use sequential and binary searches to check to see if the string is present as the instance of ArraryList. • Refer to “SearchInt.java” (given in “SearchString.zip”) and the following UML diagram for the details of required program...
Java code about writing two methods: public static String randomStringone(int length) public static String randomStringtwo(int length) This method should return a String of random lowercase letters with the given length by using for loops. To generate a random lowercase letter, use a local Random variable and the method nextInt() to generate a number between 97 and 122, then cast the result to a char. The method nextInt() can be found here: https://www.geeksforgeeks.org/java-util-random-nextint-java/ In randomStringone(), you should use String concatenation...
java
The following code is an implementation of a HeapPriorityQueue. You are to implement the methods commented with: // TODO: TIP: Do not just go from memory of your assignment implementation, be sure to consider carefully the constructor and method implementation provided to you. NOTE: You do not have to provide an implementation for any methods intentionally omitted public class Heap PriorityQueue implements PriorityQueue private final static int DEFAULT SIZE 10000 private Comparable [ ] storage private int currentSize: public...
(IN JAVA) Write a program named Review.java and implement the following methods: public static boolean isValidTicTacToeBoardString(String str) This method takes as its parameter a String that contains 9 characters representing the status of the Tic Tact Toe game. The String is mixed with X, O, x, o, and other letters. The first three letters represent the first row, letter 4 through letter 6 represent the second row, and the rest for the last row. To be considered as a valid...
Java, can you help me out thanks.
CSCI 2120 Introduction For this assignment you will implement two recursive methods and write JUnit tests for each one. You may write all three methods in the same class file. You are required to write Javadoc-style documentation for all of your methods, including the test methods. Procedure 1) Write method!! a recursive method to compare two Strings using alphabetical order as the natural order (case insensitive, DO NOT use the String class built-in...