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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 17:50, ImBADatmath8743
Farah works in an office with two other employees. all three share a printer and an internet connection. the utility that makes this possible is defragger quicktime soho winzip
Answers: 1
image
Computers and Technology, 23.06.2019 03:30, 890777
In vista and windows 7, the appearance and personalization option allows you to change the
Answers: 1
image
Computers and Technology, 23.06.2019 06:00, hilarydodard7099
Which statistical function in a spreadsheet you to see how far each number varies, on average, from the average value of the list?
Answers: 2
image
Computers and Technology, 23.06.2019 09:00, amberpublow7
Which best describes the role or restriction enzymes in the analysis of edna a. to break dna into fragments that vary in size so they can be sorted and analyzed b. to amplify small amounts of dna and generate large amounts of dna for analysis c. to purify samples of dna obtained from the environment so they can be analyzed d. to sort different sizes of dna fragments into a banding pattern that can be analyzed
Answers: 1
You know the right answer?
In the preceding exercises, you saw how one can use stepwise refinement to solve the problem of tran...

Questions in other subjects: