box around text

Ask for help with your homework/assignments in this forum!

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

box around text

Postby Henri » Fri Oct 16, 2009 12:55 pm

how do I create a box around a text that will be repeated by a loop?
example output program:
+--------------+--------+----------+
| Time Elapsed | Height | Velocity |
+--------------+--------+----------+
| 0 | 100 | 0 |
+--------------+--------+----------+
| 1 | 95 | -9.81 |
+--------------+--------+----------+
| 2 | 80.4 | -19.6 |
+--------------+--------+----------+
| 3 | 55.9 | -29.4 |
+--------------+--------+----------+
| 4 | 21.5 | -39.2 |
+--------------+--------+----------+
| 4.52 | 0 | -44.3 |
+--------------+--------+----------+
Henri
 
Posts: 6
Joined: Sun Sep 20, 2009 9:33 pm

Re: box around text

Postby Alvaro » Fri Oct 16, 2009 2:26 pm

What have you tried?

I would make a class TextTable with methods to populate the cells and with a method to print out the result. The advantage of doing it this way is that you can dynamically adjust the width of each column to accommodate the longest cell in the column.
User avatar
Alvaro
Moderator
 
Posts: 5185
Joined: Mon Sep 22, 2003 4:57 pm
Location: NY, USA


Return to Homeworks

Who is online

Users browsing this forum: shin777 and 2 guests