Hello, how would i go about achieving the following requests. I am new to this. Can i achieve all the results from once class or calling different classes. Im'm not sure if I have asked the questions correclty. Please help. Here is want i need to accomplish.
Write a program "StringManipulation.cs" in C# which accepts
two strings as command line arguments. The program should do the following:
i) print and display the total number of occurrences of the character „a? or
„A? present in both the strings
ii) replace every occurrence of „a? or „A? with @
iii) convert both the strings to upper case
iv) concatenate the two strings and display the result
Thanks
Loading

Sam HobbsRank #108 · 20.5K reputationPosted Nov 19, 2011, 10:22 PM EST
How much have you done? What specifically do you need help with? Since the question says nothing about that and instead it just describes what the assignment is, the implication is that you want someone to do everything for you. If someone did do it all for you then that would not help you learn though.
VulpesRank #55 · 29.2K reputationPosted Nov 20, 2011, 12:25 AM EST
To be able to answer this question, you need to be familiar with the String.Replace and String.ToUpper methods.
Concatenating strings can be done with the '+' operator e.g. "a" + "b" gives "ab"
You can iterate through a string using its indexer:
for(int i = 0; i < str.Length; i++)
{
char c = str[i]; // gets the 'i'th character of 'str' - starting from an index of zero
// do something with 'c' such as count its occurrences
}
You can also iterate using foreach:
foreach(char c in str)
{
// so something with 'c'
}
Mike Patel7 reputationPosted Nov 20, 2011, 12:23 PM EST
Sam HobbsRank #108 · 20.5K reputationPosted Nov 20, 2011, 1:30 PM EST
Also note that you are checking for a letter using "if (chars[i] < 'a' || chars[i] > 'z')". Think about that; what will happen for upper case?
The output is not being formatted in a way that can be read easily, but if you take care of the above then I think you will at least have useful data.