How can I make a method that takes a String and prints it out in AltCase meaning that the first letter is uppercase and each subsequent character alternates between lowercase and uppercase.
Show older comments
public String altCase(String text) {
}
Answers (2)
Stephen23
on 2 Dec 2015
>> str = 'hello world!';
>> str(1:2:end) = upper(str(1:2:end));
>> str(2:2:end) = lower(str(2:2:end))
str = HeLlO WoRlD!
Walter Roberson
on 2 Dec 2015
0 votes
First you have to show us your String class. MATLAB does not have a String class.
It looks to me that you are asking homework questions about a different programming language.
Categories
Find more on String Parsing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!