Outputting a message box.

could anyone help me print out a message box like this? The bottom and top border are supposed to be 60 columns and the side borders are supposed to be 11 rows long. Im tempted just to cout every line but I know that that wouldn't be right. I know I have to use setw, setfill, left, right and all that jazz. I'm just getting started and I'm finding it very difficult.

1
2
3
4
5
6
7
8
9
10
11
************************************************************
*                                                          *
* Course Name & Number                          Fall, 2014 *
*                                                          *
*                                                          *
*                    First & Last Name                     *
*                                                          *
*                                                          *
*                Assignment _ : Exercise _                 *
*                                                          *
************************************************************
Last edited on
Your best option (cross platform) is to just use cout. It's pretty naive, but it works.
You'll need to calculate the positions of the date, names, and assignment info.

Given N columns, the date starts at column N-2-s.length(). Now you need a subtraction to find out how many spaces to put between the end of the course-info string and the first character in the date string.

The other two things you need to calculate where to start printing something that is centered.

You can get the number of spaces between the first * and the first character in the string-to-center as:
(N+s.length())/2 - 1.

I'll leave it to you to figure out how many spaces to put after the last character in the string-to-center and the * at the end of the line.

By the way, to print n spaces, use cout << string( n, ' ' ).

Hope this helps.
Topic archived. No new replies allowed.