Hi, here is the thing, I'm trying to make my university grading table on C++, when i fill in the grades it should tell me what i have accumulate.
the thing is that when i insert the text grades it shows a zero when i click the buttom.
the math is simple [ j ] are the int and the [ i ] are the decimals they must add up and multiply by the percent which in this case is Edit5,E6,E7,E8 here is the code; acu= the acumulated [ j+(i/10)] i being the decimal.

void __fastcall TForm1::B1Click(TObject *Sender)
{  int tot1=0,tot2=0,tot3=0,tot4=0,a,b,c,d,e,f,g,h;
   float acu=0,tot=0,p;
int ma[11][10] = {
{0, 1,  2,  3,  4,  5,  6,  7,  8,  9},
{1, 100,    101,    102,    103,    58, 104,    105,    106,    95},
{2, 8,  19, 30, 41, 52, 64, 75, 86, 0},
{3, 9,  20, 31, 42, 53, 65, 76, 87, 0},
{4, 10, 21,     32, 43, 107,    66, 77, 88, 0},
{5, 11, 22,     33, 44, 56, 67, 78, 89, 0},
{6, 12, 23,     34, 45, 57, 68, 79, 90, 0},
{7, 13, 24,     35, 46, 58, 69, 80, 91, 0},
{8, 14, 35,     36, 47, 59, 70, 81, 92, 0},
{9, 15, 26, 37, 108,    60, 71, 82, 93, 0},
{10,    16, 27, 38, 50, 61, 72, 83, 94, 0}};
 a = E1->Text.ToInt();
 b = E2->Text.ToInt();
 c = E3->Text.ToInt();
 d = E4->Text.ToInt();
 e = E5->Text.ToInt();
 f = E6->Text.ToInt();
 g = E7->Text.ToInt();
 h = E8->Text.ToInt();

        for(int i=1;i<11;i++)
        for(int j=1;j<10;j++){
       if(a== ma[i][j]){
         acu=(j+(i/10));

         }
         }
      if(a<7)
        acu=1;
        if(a== 17 ||a== 18)
        acu=2;
        if(a== 28 ||a== 29)
        acu=3;
        if(a== 39 ||a== 40)
        acu=4;
        if(a== 48 ||a== 49)
        acu=4.8;
        if(a== 54 ||a== 55)
        acu=5.3;
        if(a== 62 ||a== 63)
        acu=6;
        if(a== 73 ||a== 74)
        acu=7;
        if(a== 84 ||a== 85)
        acu=8;
        }
        tot4=(acu*(e/100));
        for(int i=1;i<11;i++)
        for(int j=1;j<10;j++){
       if(b== ma[i][j])
       acu=(j+(i/10));
        if(b<7)
        acu=1;
        if(b== 17 ||b== 18)
        acu=2;
        if(b== 28 ||b== 29)
        acu=3;
        if(b== 39 ||b== 40)
        acu=4;
        if(b== 48 ||b== 49)
        acu=4.8;
        if(b== 54 ||b== 55)
        acu=5.3;
        if(b== 62 ||b== 63)
        acu=6;
        if(b== 73 ||b== 74)
        acu=7;
        if(b== 84 ||b== 85)
        acu=8;

        }
        tot3=(acu*(f/100));
        for(int i=1;i<11;i++)
        for(int j=1;j<10;j++){
       if(c== ma[i][j])
       acu=(j+(i/10));
        if(c<7)
        acu=1;
        if(c== 17 ||c== 18)
        acu=2;
        if(c== 28 ||c== 29)
        acu=3;
        if(c== 39 ||c== 40)
        acu=4;
        if(c== 48 ||c== 49)
        acu=4.8;
        if(c== 54 ||c== 55)
        acu=5.3;
        if(c== 62 ||c== 63)
        acu=6;
        if(c== 73 ||c== 74)
        acu=7;
        if(c== 84 ||c== 85)
        acu=8;
        }
        tot2=(acu*(g/100));
        for(int i=1;i<11;i++)
        for(int j=1;j<10;j++){
       if(d==ma[i][j])
       acu=(j+(i/10));
        if(d<7)
        acu=1;
        if(d== 17 ||d== 18)
        acu=2;
        if(d== 28 ||d== 29)
        acu=3;
        if(d== 39 ||d== 40)
        acu=4;
        if(d== 48 ||d== 49)
        acu=4.8;
        if(d== 54 ||d== 55)
        acu=5.3;
        if(d== 62 ||d== 63)
        acu=6;
        if(d== 73 ||d== 74)
        acu=7;
        if(d== 84 ||d== 85)
        acu=8;
        }
        tot1=(acu*(h/100));
        tot=tot1+tot2+tot3+tot4;
       L1->Caption=tot;

}

it keeps printing zeros
and the 100 101 .... are special things which are all the conditions if(d==73 || d==74)

here something extra, every time a divide i/10 it gives me zeros, and i see the zero comes when dividing things example : tot1=(acu*(h/100)); and everything multiply by zero is zero so we get zeros on the label.
how can i make the division to give the right number?

here something extra, every time a divide i/10 it gives me zeros, and i see the zero comes when dividing things example : tot1=(acu*(h/100)); and everything multiply by zero is zero so we get zeros on the label.
how can i make the division to give the right number?

If i=1, then i/10 will be zero because its truncated. Use a double

I change everything to double : double i,j,... I don't get more zeros but it won't take the decimals like i/10 = 0.1 how can i get the decimals?

I change everything to double : double i,j,... I don't get more zeros but it won't take the decimals like i/10 = 0.1 how can i get the decimals?

Example? Not sure what you're saying.

i solved the problem, when ever i did a division like 1/10 it gave me a zero, in order to get 0.1 from the division above, i use instead 1*0.1 which is the same thing and it solved the problem with the decimal now the label is showing the decimals too for the interger thanks anyway...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.