Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

hello everyone thanks in advance for your help. this is a loop imade to solve an

ID: 3614459 • Letter: H

Question

hello everyone thanks in advance for your help. this is a loop imade to solve an equation. the problem that i am having is with theoutput. The way i want it to look is so negative result/possitiveresult/zero result only display once and the corresponding y valuesshow up under their respective headlines. The problem is that sincethe negative/possitive/zero staements are inside the loop, they getdisplayed with every y value, is there anyway to take thestatements out of the loop but still show the corresponding yvalues?

for(x=-4;x<=3.5;x+=.5)
     { y= (-4* pow(x,3) +(12*(pow(x,2)))- (3*x)-5)/ (   sqrt((3*pow(x,2)+1)) + (10* abs(x-1.5)));
      
   
                
     if (y<0)
     {cout<< "NEGATIVE RESULTS ---------------- " ;
      cout<<"If x="<<setprecision(1)<<fixed<<x<<"    Y="<<setprecision (5)<<y<<endl<<endl;}
     else if (y>0)
     {cout<< "POSSITIVE RESULTS ----------------- " ;
         cout<<"If x= "<<setprecision(1)<<fixed<<x<< "    Y="<<setprecision (5)<<y<<endl<<endl;}
     else
     {cout<< "ZERO RESULTS ------------ " ;
         cout<<"If x="<<setprecision(1)<<fixed<<x<<"    Y="<<setprecision (1)<<y<<endl<<endl;}
   
   
    
     }

Explanation / Answer

please rate - thanks the only way to do it, without arrays, is have the loopexecute 3 times, showing negatives 1 time through the loop, 0's onetime through the loop, positives 1 time through the loop.