Capitalize in Every Language

Published on 31 March 2019 (Updated: 18 May 2022)

Capitalize in Every Language

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.

Description

This simple program picks a string and return the first letter of it in uppercase.

Requirements

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.

Testing

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).

Valid Tests

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

Invalid Tests

Description Input
No input
Empty input ""

All invalid tests should spit out a usage statement in the following form:

Usage: please provide a string

Articles