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

When I compile and run the program it won\'t return doubles, I enter 1.0 and it

ID: 3769526 • Letter: W

Question

When I compile and run the program it won't return doubles, I enter 1.0 and it returns 1 etc. any one know what I'm missing?

#include <iostream>
#include <cmath>
using namespace std;

int main(){
   double x_Cord= 0.0 ;
   double y_Cord= 0.0;
  
       while(x_Cord==0.0 && y_Cord==0.0){
      
cout<< "Please enter X coordinate: ";
cin>> x_Cord;
cout<< "Please enter Y coordinate: ";
cin>> y_Cord;
double temp=1.0;
if(x_Cord<0.0 && y_Cord<0.0){
   cout<<"Point"<< "("<<x_Cord<<","<<y_Cord<<")"<<"is in quadrant III."<<endl;
   }
else if(x_Cord>0.0 && y_Cord> 0.0){
   cout<<"Point "<< "("<<x_Cord<<","<<y_Cord<<")"<<" is in quadrant I"<<endl;
}
else if(x_Cord>0.0 && y_Cord<0.0){
   cout<<"Point "<< "("<<x_Cord<<","<<y_Cord<<")"<<" is in quadrant IV"<<endl;
}
else if(x_Cord<0.0 && y_Cord>0.0){
cout<<"Point "<< "("<<x_Cord<<","<<y_Cord<<")"<<" is in quadrant II."<<endl;
}
else if(x_Cord==0.0 && y_Cord==0.0){
cout<<"Point "<< "("<<x_Cord<<","<<y_Cord<<")"<<" is on the origin."<<endl;;
}
else if(x_Cord==0.0){
   cout<<"Point "<< "("<<x_Cord<<","<<y_Cord<<")"<<" is on y-axis"<<endl;
}
else if(y_Cord==0.0){
   cout<<"Point is on x-axis"<<endl;}
x_Cord=0.0;
y_Cord=0.0;
}

return 0;
}

Explanation / Answer

#include <iostream>

#include <cmath>

using namespace std;

int main(){

double x_Cord= 0.0 ;

double y_Cord= 0.0;

  

while(x_Cord==0.0 && y_Cord==0.0){

  

cout<< "Please enter X coordinate: ";

cin>> x_Cord;

cout<< "Please enter Y coordinate: ";

cin>> y_Cord;

double temp=1.0;

if(x_Cord<0.0 && y_Cord<0.0){

printf("Point (%.2lf,%.2lf) is in quadrant III", x_Cord, y_Cord);

}

else if(x_Cord>0.0 && y_Cord> 0.0){

printf("Point (%.2lf,%.2lf) is in quadrant I", x_Cord, y_Cord);

}

else if(x_Cord>0.0 && y_Cord<0.0){

printf("Point (%.2lf,%.2lf) is in quadrant IV", x_Cord, y_Cord);

}

else if(x_Cord<0.0 && y_Cord>0.0){

printf("Point (%.2lf,%.2lf) is in quadrant II", x_Cord, y_Cord);

}

else if(x_Cord==0.0 && y_Cord==0.0){

printf("Point (%.2lf,%.2lf) is on the origin.", x_Cord, y_Cord);

}

else if(x_Cord==0.0){

printf("Point (%.2lf,%.2lf) is on y-axis", x_Cord, y_Cord);

}

else if(y_Cord==0.0){

printf("Point (%.2lf,%.2lf) is on x-axis", x_Cord, y_Cord);

}

cout<<endl;

x_Cord=0.0;

y_Cord=0.0;

}

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote