Question

In: Computer Science

C# Write a console application that takes the following passage and removes every instance of the...

C#

Write a console application that takes the following passage and removes every instance of the word "not" using StringBuilder and prints the result out to the console:

I do not like them
In a house.
I do not like them
With a mouse.
I do not like them
Here or there.
I do not like them
Anywhere.
I do not like green eggs and ham.
I do not like them, Sam-I-am.

Ensure that the resulting output reads normally, in other words, it must maintain the same line breaks and not include double-spaces where there should only be a single space. The output should be identical to this:

I do like them
In a house.
I do like them
With a mouse.
I do like them
Here or there.
I do like them
Anywhere.
I do like green eggs and ham.
I do like them, Sam-I-am.

Solutions

Expert Solution

CODE -

using System;

using System.Text;

namespace stringBuilders{

class Sample{

static void Main()

{

    // Create StringBuilder object

    StringBuilder s = new StringBuilder("I do not like them\nIn a house.\nI do not like them\nWith a mouse.\nI do not like them\nHere or there.\nI do not like them\nAnywhere.\nI do not like green eggs and ham.\nI do not like them, Sam-I-am.");

    // Replace "not " with blank to remove not from the passage.

    s.Replace("not ", "");

    // Display the updated passage.

    Console.WriteLine(s);

}

}

}

SCREENSHOT -

If you have any doubt regarding the solution, then do comment.
Do upvote.


Related Solutions

write a c++ member function that removes the first instance of a specific element in a...
write a c++ member function that removes the first instance of a specific element in a linked list and then return the size of the list after the removal whether it was successful or not.
Program in C Write a function that takes a string as an argument and removes the...
Program in C Write a function that takes a string as an argument and removes the spaces from the string.
C# I need working code please Write a console application that accepts the following JSON as...
C# I need working code please Write a console application that accepts the following JSON as input: {"menu": { "header": "SVG Viewer", "items": [ {"id": "Open"}, {"id": "OpenNew", "label": "Open New"}, null, {"id": "ZoomIn", "label": "Zoom In"}, {"id": "ZoomOut", "label": "Zoom Out"}, {"id": "OriginalView", "label": "Original View"}, null, {"id": "Quality"}, {"id": "Pause"}, {"id": "Mute"}, null, {"id": "Find", "label": "Find..."}, {"id": "FindAgain", "label": "Find Again"}, {"id": "Copy"}, {"id": "CopyAgain", "label": "Copy Again"}, {"id": "CopySVG", "label": "Copy SVG"}, {"id": "ViewSVG", "label": "View...
write a c# console application app that reads all the services in the task manager and...
write a c# console application app that reads all the services in the task manager and automatically saves what was read in a Notepad txt file.  Please make sure that this program runs, also add some comments
Loops Write a simple C/C++ console application that will calculate the equivalent series or parallel resistance....
Loops Write a simple C/C++ console application that will calculate the equivalent series or parallel resistance. Upon execution the program will request ether 1 Series or 2 Parallel then the number of resisters. The program will then request each resistor value. Upon entering the last resistor the program will print out the equivalent resistance. The program will ask if another run is requested otherwise it will exit.
You've been hired by Yogurt Yummies to write a C++ console application that calculates and displays...
You've been hired by Yogurt Yummies to write a C++ console application that calculates and displays the cost of a customer’s yogurt purchase. Use a validation loop to prompt for and get from the user the number of yogurts purchased in the range 1-9. Then use a validation loop to prompt for and get from the user the coupon discount in the range 0-20%. Calculate the following:         ● Subtotal using a cost of $3.50 per yogurt.         ● Subtotal...
You've been hired by Avuncular Addresses to write a C++ console application that analyzes and checks...
You've been hired by Avuncular Addresses to write a C++ console application that analyzes and checks a postal address. Prompt for and get from the user an address. Use function getline so that the address can contain spaces. Loop through the address and count the following types of characters:         ● Digits (0-9)         ● Alphabetic (A-Z, a-z)         ● Other Use function length to control the loop. Use functions isdigit and isalpha to determine the character types. Use formatted...
Write a C++ console application that allows your user to enter the total rainfall for each...
Write a C++ console application that allows your user to enter the total rainfall for each of 12 months into an array of doubles. The program should validate user input by guarding against rainfall values that are less than zero. After all 12 entries have been made, the program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest rainfall amounts.
2) You've been hired by Superfluous Stats to write a C++ console application that analyzes a...
2) You've been hired by Superfluous Stats to write a C++ console application that analyzes a string. Prompt for and read from the user a string that may contain spaces. Then prompt for and read from the user a single character. Print the following stats about the string and character inputs. Use formatted output manipulators (setw, left/right) to print the following rows about the string:           ● The string value.           ● The string length.           ● The spot, if...
c# Create a console application that protects an XML file, such as the following example. Note...
c# Create a console application that protects an XML file, such as the following example. Note that the customer's credit card number and password are currently stored in clear text. The credit card must be encrypted so that it can be decrypted and used later, and the password must be salted and hashed: <?xml version="1.0" encoding="utf-8" ?> <customers> <customer> <name>Bob Smith</name> <creditcard>1234-5678-9012-3456</creditcard> <password>Pa$$w0rd</password> </customer> </customers>
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT