Computers and Technology, 25.12.2019 18:31 heavenwagner
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;
}
}
}
Answers: 3
Computers and Technology, 23.06.2019 12:20
When guido van rossum created python, he wanted to make a language that was more than other programming languages. a. code-based b. human-readable c. complex d. functional
Answers: 1
Computers and Technology, 23.06.2019 20:00
How much current flows through the alternator brushes? a. 2–5 a b. 25–35 a, depending on the vehicle c. 5–10 a d. 10–15 a
Answers: 2
Computers and Technology, 24.06.2019 22:00
Is the process of organizing data to reduce redundancy. a. normalization b. primary keying c. specifying relationships d. duplication
Answers: 1
Computers and Technology, 24.06.2019 23:00
Why is it preferable to code web pages in html format? a. to create more lines code b. to apply general formatting rules c. to display properly as search results in all browsers d. to add meaning to the document
Answers: 1
In the preceding exercises, you saw how one can use stepwise refinement to solve the problem of tran...
Mathematics, 04.12.2019 22:31
Mathematics, 04.12.2019 22:31
Biology, 04.12.2019 22:31
Social Studies, 04.12.2019 22:31
Mathematics, 04.12.2019 22:31
History, 04.12.2019 22:31