jeudi 3 mai 2018

List transposition

whats im trying to do is a transposition of a list i have. From a list into a table to be exact.

problem description

In the while im recieving a value which is saved in a Array{13} (this array is initialized with 0's. One per month, first 0 is not used)

month           =  rsSol.getInt("month");      // To save number of month
mon_amounth     =  rsSol.getDouble("amounth"); // Save amount in a value
values[month]   =  mon_amounth;                // Save amount in the array
monthTotal     +=  giro_montoMes;              // Sum of each mon_amounth

Then, this is the piece of my code where im stucked.

I'm a little bit confused with what condition i need to add to group description and print all amounts in the same row.

while ( rsSol.next() ) {
    //where i (re)write description
    if ( desc.equals(empty_string) ){
        desc        =  rsSol.getString("description");
    }

    if ( !desc.equals(rsSol.getString("giro")) && count > 1 ){
        desc        = rsSol.getString("giro");
    } 

    // Where i print the description
    <tr class>
        <td border='0' ALIGN='left'>    desc.toLowerCase()  </td>

        // Where i print the array
        for(int i=1; i<=12; i++){
            <td border='0' ALIGN='right'>   values[i])  </td>
        }

        // Where i print the sum of all months
        <td border='0' ALIGN='right'>   monthTotal  </td>
    </tr>

    // Setting values to 0 and cleaning the array
    mon_amounth =   0;

    for ( int i=1 ; i<=12 ; i++ ) {
        values[i] = 0;
    }
}

Any help will be really helpful. Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire