Hi i seem to have a problem with my code specifically around the area "getline(cin, sPointsXY);"
here is my code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
int iUserChoice=0;
// Menu for Calculator
cout<<"Please select one of the equations below"<<endl;
cout<<"Press 1 to select the value of Y"<<endl;
cout<<"Press 2 to select the value of M"<<endl;
cout<<"Press 3 to exit the calculator"<<endl;
cout<<"Please enter your value for M"<<endl;
cin>>fGradient;
cout<<"Now please enter your value for X"<<endl;
cin>>fPointX;
cout<<endl;
float fPointY = (fGradient * fPointX);
cout<<"M x X ="<<endl;
cout<<fPointY<<endl;
float fIntercept=0.0;
cout<<"Please enter your value for c"<<endl;
cin>>fIntercept;
cout<<endl;
float fAnswer = (fPointY + fIntercept);
cout<<"(M x X) + C ="<<endl;
cout<<"And your answer is"<<endl;
cout<<fAnswer<<endl;
}
else
{
if(iUserChoice==2)
{
// Making the Strings
std::string sPointsXY;
std::string sPointsX1Y1;
// Appying the getline so that it can accept two different values
cout<< "Enter the value of sPointsXY"<<endl;
getline(cin, sPointsXY);
cout<<"Enter the value of sPointsX1Y1"<<endl;
getline(cin, sPointsX1Y1);
std::string::size_type sz;
//Couting the formula of the equation
cout<<"Y="<<fPointsY<<endl;
cout<<"Y1="<<fPointsY1<<endl;
cout<<"Y - Y1 ="<<(fPointsY-fPointsY1)<<endl;
cout<<endl;
cout<<"X="<<fPointsX<<endl;
cout<<"X1="<<fPointsX1<<endl;
cout<<"X - X1 ="<<(fPointsX-fPointsX1)<<endl;
cout<<endl;
std::cout<<"X divided by Y= "<<((fPointsY-fPointsY1)/(fPointsX-fPointsX1))<<" This is the value of m.\n";