Hi everyone. I'm currently trying to learn programming (taking a class for it) but am stuck on why this isn't working. I'm sure its something stupid. This is the program in question:
Keep in mind that it isn't actually done yet, I haven't gotten to 'case 4' yet.
using namespace std;
//Decleration of varibles.
float x1, x2, y1, y2, X, slope;
//the initial looping statement.
//The menu in which the user has a choice of which option to choose.
cout << "1- Imput two points." << endl;
cout << "2- Calculate slope and Y-Intercept values." << endl;
cout << "3- Calculate Y" << endl;
cout << "4- Calculate X" << endl;
cout << "5- exit program" << endl << endl;
cin >> option;
cout << endl << endl;
//switch statement for which option has been chosen.
cout << endl;
cout << "Please enter X1" << endl;
cin >> x1;
cout << "Please enter Y1" << endl;
cin >> y1;
cout << "Please enter X2" << endl;
cin >> x2;
cout << "Please enter Y2" << endl;
cin >> y2;
cout << endl;
cout << "The slope is: " << segment1.getSlope() << endl;
cout << "The y Intercept is: " << segment1.getIntercept() << endl;
cout << "Enter a value for X." << endl;
cin >> X;
cout << "The value of Y is: " << segment1.getY(X) << endl;
cout << "Have a nice day." << endl << endl;
cout << "Invalid option, try again." << endl << endl;
pointsSet = false;
float Segment::getX(float y)
// add code
float Segment::getY(float x)
void Segment::setPoints(float x1, float y1, float x2, float y2)
pointsSet = true;
X1 = x1;
X2 = x2;
Y1 = y1;
Y2 = y2;
I'm getting a new problem. Right now it's giving me a garbage value for yIntercept, but it changes with what i imput. For example I imput:
and I get displayed to the screen:
The slope is: 1
The y Intercept is: -3.16992e+034
so obviously it isn't calculating the y Intercept correctly. Any ideas?