A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Capitalize page! Here, you’ll find a description of the project as well as a list of sample programs written in various languages.
This simple program picks a string and return the first letter of it in uppercase.
For this sample program, each solution should return the string with the first letter in uppercase. For example, the following code should return “Capitalize”:
$ ./capitalize.lang "capitalize"
Capitalize
Here are some additional examples:
string -> String
react -> React
java -> Java
car -> Car
a long string term -> A long string term
In addition, there should be some error handling for situations where the user doesn’t input a string.
Every project in the Sample Programs repo should be tested. In this section, we specify the set of tests specific to Capitalize. To keep things simple, we split up testing into two subsets: valid and invalid. Valid tests refer to tests that occur under correct input conditions. Invalid tests refer to tests that occur on bad input (e.g., letters instead of numbers).
Description | Input | Output |
---|---|---|
Lowercase String | "hello" |
Hello |
Uppercase String | "Hello" |
Hello |
Long String | "hello world" |
Hello world |
Mixed Casing | "heLLo World" |
HeLLo World |
Symbols | "12345" |
12345 |
Description | Input |
---|---|
No input | |
Empty input | "" |
All invalid tests should spit out a usage statement in the following form:
Usage: please provide a string