samedi 29 octobre 2016

creating a function that returns a string

i'm trying to create a function that takes in numbers and outputs the number in English. for example if the user entered 5 the function should output "five". here is the code i have so far.

string GetEnglishOnes(int ones) {
switch (ones) {
case 1: onesInEnglish = "one"; break;
case 2: onesInEnglish = "two"; break;
case 3: onesInEnglish = "three"; break;
case 4: onesInEnglish = "four"; break;
case 5: onesInEnglish = "five"; break;
case 6: onesInEnglish = "six"; break;
case 7: onesInEnglish = "seven"; break;
case 8: onesInEnglish = "eight"; break;
case 9: onesInEnglish = "nine"; break;
return onesInEnglish;
}
}  

any help will be appreciated

Aucun commentaire:

Enregistrer un commentaire