Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi, I need to create a function that converts an integer in the range of 0-99 in

ID: 3650119 • Letter: H

Question

Hi,

I need to create a function that converts an integer in the range of 0-99 into a string containing exactly two characters. I.E "00", "01", "10", "11", etc. It should take a single integer parameter and return a string.

I have chosen the name two digits and am thinking I need to use a string stream of some sort. Ideas?

Explanation / Answer

#include 02 #include 03 #include 04 05 using namespace std; 06 07 08 09 int main (int argc, char** argv) 10 { 11 int totalHrs = 0; 12 int totalMins = 0; 13 int totalSecs = 0; 14 15 int hrs; 16 while (cin >> hrs) 17 { 18 // Read a song 19 int min, sec; 20 string title; 21 cin >> min >> sec >> ws; 22 getline (cin, title); 23 24 // Normalize the time and print the song (This should be the normalize function) 25 int m = sec / 60; 26 sec = sec % 60; 27 min += m; 28 int h = min / 60; 29 hrs += h; 30 min = min % 60; 31 32 // Pad the title to 40 characters (I believe this should become the twoDigits function) 33 title = title + string(40, ' '); 34 title = title.substr(0, 40); 35 36 cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote