programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering OS Languages Paradigms IDEs Build Tools Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# Table Manipulation

Sean Derik
Greenhorn
Posts: 2
This problem is an exercise in organizing a one-dimensional list of
numbers into a 2-dimensional table with a variable number of columns.
The numbers must be organized into a table which reads by columns, left
to right. The lengths of the columns should be balanced so that all rows
except the last are filled. The empty spaces in the last row should be
at the right end of the row.

EXAMPLE:

LIST: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17

COLUMNS: 5

TABLE: 1  5  9 12  15
2 6 10 13  16
3 7 11 14 17
4 8

Write a program to read a collection of records (c-, 10,000) each with
a positive integer in columns 1-5. A zero value terminates the list. A
second set of records should be read next, with various positive integer
values for C, the number of columns, in columns 1-5. After each value
of C is read, the sum of the elements in each row of the table should be
computed and printed. Sums will be less than 9 digits. The 2-dimensional
table itself should not be printed.
Using the sample data shown above for various values of C, output
similar to the following should be produced:

C ROW SUMS

5 42 47 52 12
************************************
1 , 153
************************t***********
2 11 13. 15 17 19 21 23 25 9
************************************
Either vertical or horizontal printing of row sums is acceptable, but a
line of asterisks should separate output generated for different values
of C. A zero value for C should cause the program to terminate.

(I am confused with this problem, could some one help me with this problem)

Campbell Ritchie
Marshal
Posts: 56570
172
• 1
Welcome to the Ranch

How far have you got with your assignment? Start by writing down what you think it means. Or what the first part of it means.

Sean Derik
Greenhorn
Posts: 2
to be honest i am a starter and i have gone through it many time but can think of a wy of writing the code, about the problem i think that when we give some numbers as keyboard input as a list that 2D table has to be created.

Campbell Ritchie
Marshal
Posts: 56570
172
Write down what the first stage of the program would be.

 It is sorta covered in the JavaRanch Style Guide.