Question

In: Computer Science

Using C# .NET Core console application that contains the following: 1. Use this variable: string baconIpsum...

Using C# .NET Core console application that contains the following:

1. Use this variable:

string baconIpsum = "Bacon ipsum dolor amet picanha tri-tip pig pork bacon turducken. Leberkas short ribs prosciutto pork belly ribeye capicola alcatra short loin ham hock rump jowl pig flank beef. Venison tenderloin tail, cupim salami pastrami meatball jerky filet mignon. Salami jerky short loin, chicken pig pork tenderloin rump meatball sausage pancetta sirloin. Drumstick tenderloin ham pork belly cupim, ground round prosciutto jerky ball tip kielbasa tongue andouille picanha alcatra. Ham ribeye t-bone, boudin buffalo pork chop beef tri-tip. Bacon filet mignon frankfurter kevin, pork chop burgdoggen bacon bacon ham hock beef ribs bresaola turkey meatball corned beef.";

2. Use string manipulation, output of a count of how many sentences are in your string variable

3. Use a loop to iterate through each sentence

4. If the string "bacon" is found in the sentence, output a happy sentence, otherwise, output a sad sentence to the console

5. Output how many times bacon is in baconIpsum and tell if that is enough bacon for you

Solutions

Expert Solution

Application Name :baconApplication

Type of Application :Console Application

IDE used :Visual Studio 2019

Program.cs :

//namespace
using System;
//application namespace
namespace baconApplication
{
class Program //C# class
{
//Main() method
static void Main(string[] args)
{
//declaring variable baconIpsum
string baconIpsum = "Bacon ipsum dolor amet picanha tri-tip pig pork bacon turducken. Leberkas short ribs prosciutto pork belly ribeye capicola alcatra short loin ham hock rump jowl pig flank beef. Venison tenderloin tail, cupim salami pastrami meatball jerky filet mignon. Salami jerky short loin, chicken pig pork tenderloin rump meatball sausage pancetta sirloin. Drumstick tenderloin ham pork belly cupim, ground round prosciutto jerky ball tip kielbasa tongue andouille picanha alcatra. Ham ribeye t-bone, boudin buffalo pork chop beef tri-tip. Bacon filet mignon frankfurter kevin, pork chop burgdoggen bacon bacon ham hock beef ribs bresaola turkey meatball corned beef.";
//converting string baconIpsum to array
string[] sentenceCount = baconIpsum.Split(".");
//print number of sentence
Console.WriteLine("Number of sentences are in string variable baconIpsum :" + (sentenceCount.Length-1));
//declared variable to store to count word bacon in baconIpsum
int countBacon = 0;
//using for loop
for (int i = 0; i < sentenceCount.Length-1; i++)
{
//checking if sentence contains string bacon
if (sentenceCount[i].ToLower().Contains ("bacon"))
{
countBacon++;//increment bacon count
//when sentence contains string bacon
//print sentence and string happy sentence
Console.WriteLine(sentenceCount[i]+ ". : happy sentence");
}
else
{
//when sentence does not contains string bacon
//print sentence and string sad sentence
Console.WriteLine(sentenceCount[i] + ". : sad sentence");
}
}
Console.WriteLine("Bacon count : "+countBacon);
  
}
}
}
===============================================

Output :


Related Solutions

Create a C# console application (do not create a .NET CORE project) and name the project....
Create a C# console application (do not create a .NET CORE project) and name the project. Generate two random integers, each between 1 and 50, that you will be adding together to test the user's ability to perform the addition operator. Display the numbers in the console, such as:             7 + 22 = ? Once the user provides their answer, check to see if it is correct and if not, tell them sorry, please try again. If their answer...
Create a C# console application (do not create a .NET CORE project) and name the project...
Create a C# console application (do not create a .NET CORE project) and name the project TuitionIncrease. The college charges a full-time student $12,000 in tuition per semester. It has been announced that there will be a tuition increase by 5% each year for the next 7 years. Your application should display the projected semester tuition amount for the next 7 years in the console window in the following format:             The tuition after year 1 will be $12,600. Note:...
Create a C# console application (do not create a .NET CORE project) and name the project...
Create a C# console application (do not create a .NET CORE project) and name the project TimeToBurn. Running on a particular treadmill, you burn 3.9 calories per minute. Ask the user how many calories they wish to burn in this workout session (this is their goal). Once they tell you, output on the console after each minute, how many calories they have burned (e.g. After 1 minute, you have burned 3.9 calories). Keep outputting the total amount of calories they...
Create a C# .NET Core Console project in Visual Studio. (This is the same kind of...
Create a C# .NET Core Console project in Visual Studio. (This is the same kind of project we have been doing all semester.) Do all of the following in the Program class. You do not need to add any other classes to this project. 2. If it exists, remove the Console.WriteLine(“Hello World!”); line that Visual Studio created in the Program class. 3. At the very top of the Program.cs page you should see using System; On the empty line below...
1. Make a Console App (.NET Core) in Visual Studio and name it as A1YourFirstnameLastname. 2....
1. Make a Console App (.NET Core) in Visual Studio and name it as A1YourFirstnameLastname. 2. Implement a vehicle rental management system which is capable of doing the following: • View all, available and reserved vehicles. • Reserve vehicle or cancel a reservation. 3. The application must be menu-based app: 1 - View all vehicles 2 - View available vehicles 3 - View reserved vehicles 4 - Reserve a vehicle 5 - Cancel reservation 6 - Exit 4. NOTE: At...
Shopping Cart App (C#) Please create a C# Console (.NET Framework) application which reads from the...
Shopping Cart App (C#) Please create a C# Console (.NET Framework) application which reads from the user, the price of items in their shopping "cart". Be sure to tell the user how to stop (or ask them if they want to stop) entering prices. Items can be priced any positive number greater than zero. When the user has entered the prices for all items in their "cart", calculate the subtotal (the sum of all item prices). Next, check if the...
use c++ (1) Prompt the user for a string that contains two strings separated by a...
use c++ (1) Prompt the user for a string that contains two strings separated by a comma. (1 pt) Examples of strings that can be accepted: Jill, Allen Jill , Allen Jill,Allen Ex: Enter input string: Jill, Allen (2) Print an error message if the input string does not contain a comma. Continue to prompt until a valid string is entered. Note: If the input contains a comma, then assume that the input also contains two strings. (2 pts) Ex:...
Write a Java console application that reads a string for a date in the U.S. format...
Write a Java console application that reads a string for a date in the U.S. format MM/DD/YYYY and displays it in the European format DD.MM.YYYY  For example, if the input is 02/08/2017, your program should output 08.02.2017
ONLY USE VISUAL STUDIO (NO JAVA CODING) VISUAL STUDIO -> C# -> CONSOLE APPLICATION In this...
ONLY USE VISUAL STUDIO (NO JAVA CODING) VISUAL STUDIO -> C# -> CONSOLE APPLICATION In this part of the assignment, you are required to create a C# Console Application project. The project name should be A3<FirstName><LastName>P2. For example, a student with first name John and Last name Smith would name the project A1JohnSmithP2. Write a C# (console) program to calculate the number of shipping labels that can be printed on a sheet of paper. This program will use a menu...
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