Question: For this task, please submit only the twoDigitString function, whose shell is as follows: / * * * Formats a number as 2 digits, with

For this task, please submit only the twoDigitString function, whose shell is as follows:
/**
* Formats a number as 2 digits, with a leading 0 if needed
*
* @param n number to format, assumed between 0 and 59, inclusive
* @return two digit string representation of number
*/
string twoDigitString(unsigned int n)
To implement this method, you should:
Check if the number is between 0 and 9. If it is, tack a "0" onto the front of the string representation of the number.
Convert the number to a string using your programming language's built-in functions.
Return the resulting string.
Remember that the resulting string should always be 2 digits long. So, if the input number is 0, the output should be "00".

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!