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, 23.06.2019 14:00
How are stop motion special effects in animated films created
Answers: 1
question
Computers and Technology, 24.06.2019 23:00
The valves of the heart and veins are similar in that they both
Answers: 1
question
Computers and Technology, 25.06.2019 01:00
Your computer will organize files into order. alphabetical chronological size no specific
Answers: 2
question
Computers and Technology, 25.06.2019 04:30
Which relativos possible when two tables share the same primary key? a.) one-to-one b.) one-to-many c.) many-to-one d.) many-to-many
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
History, 21.01.2021 21:00
question
Mathematics, 21.01.2021 21:00
question
Mathematics, 21.01.2021 21:00
question
History, 21.01.2021 21:00
Questions on the website: 13722363