#include<iostream> #include<cmath> using namespace std; int main() //Declaring m
ID: 3614548 • Letter: #
Question
#include<iostream>#include<cmath>
using namespace std;
int main()
//Declaring my variables here.While the num and denom may not benecssary by seperating them I made it easier to catch any errors Imay have made
//zero,neg and pos were required to keep counters for how manytimes y was negative,zero or positive
{double x,y,num,denom,neg,zero,pos;
cout<<"Please enter the number -4 for x ";
//starting my do-while loop here
cin>>x;
cout<<"Please enter a number for x ";
do
{
num= (-4*pow(x,3.0)+12*pow(x,2.0)-3*x-5);
denom= (sqrt(3*pow(x,2.0))+1)+10*abs(x-1.5);
y=(num/denom);
cout<<"x= "<<x;
cout<<" y="<<y<<" ";
if(y<0)
{cout<<"Y IS NEGATIVE ";
neg++;}/*this is how we keep track of how many times y isnegative,zero or positive */
if(y==0)
{cout<<"Y EQUALS ZERO ";
zero++;}
if(y>0)
{cout<<"Y IS POSITIVE ";
pos++;}
x=x+0.5;}
//It is neccesary to use the and operator here or we end up with aninfinite loop.
while(x>=-4&&x<=3.5);
cout<<"Y is negative "<<neg<<" times ";
cout<<"Y equals zero "<<zero<<" times ";
cout<<"Y is positive "<<pos<<" times ";
cout<<endl;
cout<<"The Program is now complete ";
system ("pause");
return 0;
}
Im supposed to have the user enter -4 and 3.5 but cant figure thatout and the count on instances of positive, negative and zero isoff and cant figure out y
plz help!
Explanation / Answer
please rate - thanks I looked at nothing more then to answer the question You never initialized the counters to 0 using namespace std; int main() //Declaring my variables here.While the num and denom may not benecssary by seperating them I made it easier to catch any errors Imay have made //zero,neg and pos were required to keep counters for how manytimes y was negative,zero or positive {doublex,y,num,denom,neg=0,zero=0,pos=0; coutx; coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.