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 21:30
The graph shows median weekly earnings for full-time workers according to education level. which can you not conclude?
Answers: 2
question
Computers and Technology, 23.06.2019 16:50
15: 28read the summary of "an indian's view of indian affairs."15 betterin "an indian's view of indian affairs," it is asserted that conflicts could be reduced if white americansunderstood native americans..pswhich of the following would make this summary more complete? eleo the fact that chief joseph believes the great spirit sees everythinthe fact that chief joseph was born in oregon and is thirty-eight years oldo the fact that chief joseph states that he speaks from the hearthehehethe fact that chief joseph of the nez percé tribe made this claimebell- ==feetle===-felsefe ==submitmark this and retum.=
Answers: 3
question
Computers and Technology, 24.06.2019 00:30
Setting up a home network using wireless connections is creating a a. vpn b. lan c. wan d. mini-internet
Answers: 2
question
Computers and Technology, 24.06.2019 10:50
In 2009 to 2010, how many social network users were reported as being victims of online abuse? a. 1 in 10 b. 100% c.1 in 100 d. 50%
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
Medicine, 09.04.2020 20:25
question
Physics, 09.04.2020 20:26
question
Mathematics, 09.04.2020 20:26
question
Mathematics, 09.04.2020 20:26
question
Mathematics, 09.04.2020 20:26
Questions on the website: 13722362