hello all I'm building a program and it seems I can't gets my while loop to work check it out
Code:
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
class point
{
private: int x ,y;
public:
//================================================================================================
void read()
{
cout<<"Enter a fraction: ";
cin>>x; cin.ignore(); cin>>y;
}
//================================================================================================
void show()
{
cout<<x<<"/"<<y;
}
//================================================================================================
friend point operator + (point p, point q)
{
point res;
res.x = (p.x * q.y) + (q.x * p.y);
res.y = (q.y * p.y);
return res;
}
//================================================================================================
friend point operator - (point p, point q) //operator overload for subtraction
{
point res;
res.x = (p.x * q.y) - (q.x * p.y);
res.y = (q.y * p.y);
return res;
}
//================================================================================================
friend point operator / (point p, point q)//operator overload for division
{
point res;
res.x = (p.x * q.y);
res.y = (p.y * q.x);
return res;
}
};
int main()
{
point a , b;
char d; //variable d assigned for user input to cont. prog.
char e; //variable e assigned to decide type of operation
while(d !='n')
{
cout<<"What kind operation would you like to perform:";
cin>>e; //user inputs variable e
//===============================================================================================
switch(e) //beginning of switch to decide which path of logic to use
{
case '+':
a.read();
b.read();
point r1 = a + b;
a.show();
cout<<" + ";
b.show();
cout<<" = ";
r1.show();
cout<<"\nWould you like to continue:Y/N? "; cin>>d;
if(d ='n')
return 0;
break;
//===============================================================================================
case '-':
a.read();
b.read();
point r2 = a - b;
a.show();
cout<<" - ";
b.show();
cout<<" = ";
r2.show();
cout<<"\nWould you like to continue:Y/N? "; cin>>d;
if(d='n')
return 0;
break;
//================================================================================================
case '/':
a.read();
b.read();
point r3 = a / b;
a.show();
cout<<char(246);
b.show();
cout<<" = ";
r3.show();
cout<<"\nWould you like to continue:Y/N? "; cin>>d;
if(d='n')
return 0;
break;
}
}
}
any suggestions