Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please provide the program code and output in C# language for the following: 1. Given a string and a non-negative int n, return a larger

Please providethe program code and output in C# languagefor the following:

1. Given a string and a non-negative int n, return a larger string that is n copies of the original string.

StringTimes(\"Hi\", 2) -> \"HiHi\"

StringTimes(\"Hi\", 3) -> \"HiHiHi\"

StringTimes(\"Hi\", 1) -> \"Hi\"

public string StringTimes(string str, int n) {

}

2. Given a string and a non-negative int n, we'll say that the front of the string is the first 3 chars, or whatever is there if the string is less than length 3. Return n copies of the front;

FrontTimes(\"Chocolate\", 2) -> \"ChoCho\"

FrontTimes(\"Chocolate\", 3) -> \"ChoChoCho\"

FrontTimes(\"Abc\", 3) -> \"AbcAbcAbc\"

public string FrontTimes(string str, int n) {

}

3. Count the number of \"xx\" in the given string. We'll say that overlapping is allowed, so \"xxx\" contains 2 \"xx\".

CountXX(\"abcxx\") -> 1

CountXX(\"xxx\") -> 2

CountXX(\"xxxx\") -> 3

public int CountXX(string str) {

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Statistics For Engineering And The Sciences

Authors: William M. Mendenhall, Terry L. Sincich

6th Edition

1498728855, 978-1498728850

More Books

Students also viewed these Programming questions