Please help

I'm having a problem with a program I have to write for an introductory c++ class. The description for the assignment is:

"Write a program that inputs a time in the format of HHMMSS. HH is the hours, MM is the minutes, and SS is the seconds. Do not use characters! The time HHMMSS, a positive integer, will extract the individual digits to the following objects hours, minutes, and seconds. Then output the hours and four blank spaces, minutes and four blank spaces, and seconds. For the four blank spaces between the digits, you must use setw(n). See the Output for the required format."

The trouble I'm having is that the chapter the assignment comes from doesn't explain how to extract 2 digits from one integer object and assign that value to another integer object. Also, since my professor specifies that we must use setw() to apply the formatting, I believe the concatenation at the end of the sample code is incorrect. The partial code that was provided to me is below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>

#include <iomanip>

using namespace std;

int main( )
{
    int time;
    int hours;
    int minutes;
    int seconds;
	
    cout << "Enter the time (format HHMMSS): ";
    cin  >> time;

    // calculation for the two digit hours, minutes, and seconds	
    hours = _____________________________________________________;
    minutes = ___________________________________________________;
    seconds = ___________________________________________________;

    cout << hours << "      " << minutes << "      " << seconds << endl;
    
    return 0;
}
Nevermind, I just did it mathematically.

hours = time / 10000;
time = time % 10000;
etc.

Simple enough.
Topic archived. No new replies allowed.