Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone tell me what is wrong with this code and how to fix it? import components.simplereader.SimpleReader; import components.simplereader.SimpleReader1L; import components.simplewriter.SimpleWriter; import components.simplewriter.SimpleWriter1L; import components.xmltree.XMLTree;

Can someone tell me what is wrong with this code and how to fix it?

import components.simplereader.SimpleReader; import components.simplereader.SimpleReader1L; import components.simplewriter.SimpleWriter; import components.simplewriter.SimpleWriter1L; import components.xmltree.XMLTree; import components.xmltree.XMLTree1;

/** * Put a short phrase describing the program here. * * @author Put your name here * */ public final class longestText {

/** * Private constructor so this utility class cannot be instantiated. */ private LeafCount() { }

private static String longestText(XMLTree t) {

String longest = ""; int max = 0; int count = 0; if (t.isTag()) { for (int i = 0; i < t.numberOfChildren(); i++) { longest = longestText(t.child(i)); if (!t.child(i).isTag()) { count = t.child(i).label().length(); if (count > longest.length()) { longest = t.child(i).label();

}

}

}

}

return longest; }

public static void main(String[] args) { SimpleReader in = new SimpleReader1L(); SimpleWriter out = new SimpleWriter1L();

out.println("Please enter an RSS link: "); String web = in.nextLine();

XMLTree xml = new XMLTree1(web);

String word = longestText(xml); out.println(word); in.close(); out.close(); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

Handling the retransmitted packet for estimation timeout interval

Answered: 1 week ago