Hi Programmers,
Am working on a project, event made me completely lost touch with Coding, but now i want to be back fully. Am trying to get an OUTPUT using if/if else statement, my code has no errors but does not return result either, Any help or idea on what to do/advice: Here's is sample code: Kindly note: I pasted the section that is problematic:

        PA=((1.1*P2)/(1.46*P3));
        B=3*P4;
        D= P4;
if (B>PA){
          FN=(((P2*1.10)/B)-(1.4*D*P1));//if 3t>Area
          Z=0.5*(B-P4);//if 3t>Area
          M=((Z*Z)*(FN/2));//if 3t>area
          d=D-0.06;//if 3t>Area
          K=(M/(1000*d*d*P5)); //if 3t>area  
          if(K>0.156){
                JOptionPane.showMessageDialog(null,"Wide Strip is not Suitable: Select Other Type of Foundation");
            }else if(K<0.156&&P6==250){
            Zn=d*940;//for 3t>area
            As1=((M*1000000000)/(95*P6*Zn));
            ASmin=2400*D;
            AS=max(As1,ASmin);
            Qt=AS/10;
             if(Qt<110){
                bb=12;
                xx=((22*bb*bb)/28);
                nn=(AS/xx)+1;
                Asp=xx*nn;
                S=((1000*xx)/Asp);
                barTxt.setText(""+bb);
                sTxt.setText(""+S);
            }if(Qt>109&&Qt<200){
                bb=16;
                xx=((22*bb*bb)/28);
                nn=(AS/xx)+1;
                Asp=xx*nn;
                S=((1000*xx)/Asp);
                barTxt.setText(""+bb);
                sTxt.setText(""+S);
            }if(Qt>199&&Qt<310){
                bb=20;
                xx=((22*bb*bb)/28);
                nn=(AS/xx)+1;
                Asp=xx*nn;
                S=((1000*xx)/Asp);
                barTxt.setText(""+bb);
                sTxt.setText(""+S);
            }if(Qt>309&&Qt<490){
                bb=25;
                xx=((22*bb*bb)/28);
                nn=(AS/xx)+1;
                Asp=xx*nn;
                S=((1000*xx)/Asp);
                barTxt.setText(""+bb);
                sTxt.setText(""+S);
            }if(Qt>489&&Qt<800){
                bb=32;
                xx=((22*bb*bb)/28);
                nn=(AS/xx)+1;
                Asp=xx*nn;
                S=((1000*xx)/Asp);
                barTxt.setText(""+bb);
                sTxt.setText(""+S);
            }if(Qt>799){
                bb=40;
                xx=((22*bb*bb)/28);
                nn=(AS/xx)+1;
                Asp=xx*nn;
                S=((1000*xx)/Asp);
                barTxt.setText(""+bb);
                sTxt.setText(""+S);
            }

        }else if(K<0.156&&P6!=250){
           Zn=d*940;//for 3t>area
           As1=((M*1000000000)/(95*P6*Zn));
           ASsmin=1300*D;
           AS1=max(As1,ASmin);
           Qt1=AS1/10;
             if(Qt1<110){
                bb=12;
                xx=((22*bb*bb)/28);
                nn=(AS1/xx)+1;
                Asp=xx*nn;
                S=((1000*xx)/Asp);
            }if(Qt1>109&&Qt<200){
                bb=16;
                xx=((22*bb*bb)/28);
                nn=(AS1/xx)+1;
                Asp=xx*nn;
                S1=((1000*xx)/Asp);
                barTxt.setText(""+bb);
                sTxt.setText(""+S1);
            }if(Qt1>199&&Qt<310){
                bb=20;
                xx=((22*bb*bb)/28);
                nn=(AS1/xx)+1;
                Asp=xx*nn;
                S1=((1000*xx)/Asp);
                barTxt.setText(""+bb);
                sTxt.setText(""+S1);
            }if(Qt1>309&&Qt<490){
                bb=25;
                xx=((22*bb*bb)/28);
                nn=(AS1/xx)+1;
                Asp=xx*nn;
                S1=((1000*xx)/Asp);
                barTxt.setText(""+bb);
                sTxt.setText(""+S1);
            }if(Qt1>489&&Qt<800){
                bb=32;
                xx=((22*bb*bb)/28);
                nn=(AS1/xx)+1;
                Asp=xx*nn;
                S1=((1000*xx)/Asp);
                barTxt.setText(""+bb);
                sTxt.setText(""+S1);
            }if(Qt1>799){
                bb=40;
                xx=((22*bb*bb)/28);
                nn=(AS1/xx)+1;
                Asp=xx*nn;
                S1=((1000*xx)/Asp);
                barTxt.setText(""+bb);
                sTxt.setText(""+S1);
            }
          }
        }   

Recommended Answers

All 5 Replies

The first thing to do is to fix your indentation to match exactly the { and } in your code. That will help you see where blocks end and which if's the else's match up with. If you are using an IDE or programmer's editor, use that for the indentation becuase it won't make mistakes.

Thanks, actually i think the condition were quite many hence the confusion, am usin Netbeans, for example, this work perfectly well,

PA=((1.1*P2)/(1.46*P3));
        B=3*P4;
        D= P4;

        if (B>PA){
            txtB.setText(""+B);
            txtD.setText(""+D);
        }
        if (B<PA){
         B1=PA+0.02;
         D1=((B-P4)/2);
         txtB.setText(""+B1);
         txtD.setText(""+D1);

because of only two conditions, but the question i posted contain several If conditions, and no error, but no output, it's giving me sleepless night, though datz part of the programmers chalenge

am usin Netbeans

So that's Source/Format to get the indentation right. Easy.

Thanx for your quick response, what is the effect or importance of Source/Format, i just turned it ON on my Netbean IDE, how will help me out of my quagmire

With your code in the current edit window select the "Format" item from the "Source" menu. It will fix all the formatting and indentation of your code. It's not a switch that you can turn or off, it just reformats your current code each time you select it.

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.