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:

main.cpp:

Keep in mind that it isn't actuallyCode:#include <iostream> #include "Segment.h" using namespace std; int main() { //Decleration of varibles. int option; float x1, x2, y1, y2, X, slope; Segment segment1; //the initial looping statement. do { //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. switch(option) { case 1: 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; segment1.setPoints(x1,y1,x2,y2); break; case 2: cout << "The slope is: " << segment1.getSlope() << endl; cout << "The y Intercept is: " << segment1.getIntercept() << endl; break; case 3: cout << "Enter a value for X." << endl; cin >> X; cout << "The value of Y is: " << segment1.getY(X) << endl; break; case 4: break; case 5: cout << "Have a nice day." << endl << endl; break; default: cout << "Invalid option, try again." << endl << endl; } } while (option!=5); return 0; }doneyet, I haven't gotten to 'case 4' yet.

segment.cpp:

Code:#include "Segment.h" Segment::Segment() { pointsSet = false; } float Segment::getIntercept() { float yIntercept; yIntercept=Y1-(slope*X1); return yIntercept; } float Segment::getSlope() { float slope; slope=(Y2-Y1)/(X2-X1); return slope; } float Segment::getX(float y) { float x; // add code return x; } float Segment::getX1() { return X1; } float Segment::getX2() { return X2; } float Segment::getY(float x) { float y; y=(slope*x)+yIntercept; return y; } float Segment::getY1() { return Y1; } float Segment::getY2() { return Y2; } bool Segment::pointsAdded() { return pointsSet; } void Segment::setPoints(float x1, float y1, float x2, float y2) { pointsSet = true; X1 = x1; X2 = x2; Y1 = y1; Y2 = y2; }

edit:

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:

X1: 4

Y1: 5

X2: 6

Y2: 6

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?