subject

In the preceding exercises, you saw how one can use stepwise refinement to solve the problem of translating wiki markup to html. now turn the pseudocode into code. complete the converttohtml and nextsymbol methods in the following class.

import java. util. scanner;
public class wikimarkup
{
public static void main(string[] args)
{
scanner in = new scanner(system. in);
string message = in. nextline();
system. out. println(converttohtml(message));
}

/**
converts a message with wiki markup to html.
@param message the message with markup
@return the message with wiki notation converted to html
*/
public static string converttohtml(string message)
{
string result = message;
. .
return result. replace("\\", "");
}

/**
finds the next unescaped symbol.
@param message a message with wiki markup
@param symbols the symbols to search for
@param start the starting position for the search
@return the position of the next markup symbol at or after start
*/
public static int nextsymbol(string message, string symbols, int start)
{
. .
}

/**
gets the html tag for a markup symbol.
@param symbol the markup symbol
@return the corresponding html tag, or null if none found
*/
public static string tagforsymbol(char symbol)
{
if (symbol == '! ') { return "em"; }
else if (symbol == '*') { return "strong"; }
else if (symbol == '`') { return "code"; }
else if (symbol == '^') { return "super"; }
else if (symbol == '_') { return "sub"; }
else { return null; }
}

/**
replaces a character of a string at a given position.
@param str the string where the replacement takes place
@param position the position of the character to be replaced
@param replacement the replacement string, or the original string
if position was not valid.
*/
public static string replaceat(string str, int position,
string replacement)
{
if (0 < = position & & position < str.
{
return str. substring(0, position) + replacement +
str. substring(position + 1);
}
else
{
return str;
}
}
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:50
Using least squares fitting, you are to fit the data sets to the following models and solve for the parameters ai , where i is the index of the parameter. the input/output data for the systems are linked in the bblearn site. for each of the systems use matlab to plot the supplied data vs. the model fit on one plot. include your code in the solutions. (a) linear fit "lineardata.mat" y=a1x^3 + a2x^2 + a3x + a4 (b) plant fit "plantdata.mat g(s) = a1/(s + a2)
Answers: 1
question
Computers and Technology, 22.06.2019 20:00
When you mouse over and click to add a search term this(these) boolean operator(s) is(are) not implied. (select all that apply)?
Answers: 1
question
Computers and Technology, 23.06.2019 18:40
How does is make you feel when you're kind to others? what are some opportunities in your life to be more kind to your friends and loved ones? imagine a world where kindness has be outlawed. how would people act differently? would your day-to-day life change significantly? why or why not?
Answers: 2
question
Computers and Technology, 24.06.2019 13:00
George heard about the benefits of a data warehouse. he wants to try implementing one for his organization. however, he is afraid that transferring data to the data warehouse will affect transaction time. which element ensures that transactions are not affected when moving data to a warehouse? when data is transferred to a data warehouse, the a area frees the source system to continue transaction processing.
Answers: 2
You know the right answer?
In the preceding exercises, you saw how one can use stepwise refinement to solve the problem of tran...
Questions
question
Mathematics, 16.09.2021 08:40
question
Mathematics, 16.09.2021 08:40
question
Mathematics, 16.09.2021 08:40
question
Mathematics, 16.09.2021 08:40