thread stopped?? ..

ok this is my coding and im using the borland c++ compiler

edit: sori for not usin the tag codes, i still don't know whats wrong, never get a thread error before..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#include<iostream>
#include<conio.h>
#include<iomanip.h>

void getProblem();
void get2Pt();
float SlopeInteptFrom2Pt(float,float,float,float);
float display2Pt(float,float,float,float);

void getPtSlope();
float InteptFromPtSlope(float,float,float);
float displayPtSlope(float,float,float);

float displaySlopeIntept(float,float);

void main()
{
	getProblem();
	getch();
	return;
}

void getProblem()
{
	int choice;
   char conv='y' ;
   while (conv=='y'||conv=='Y')
   {
		cout<<"Select the form that you would like to convert to slope intercept form:"<<endl;
   	cout<<"1)	Two- point form ( you know two points on the line)"<<endl;
   	cout<<"2)	Point -slope form ( you know the line's  slope and one point)"<<endl;
      cout<<endl;
      cin>>choice;

      switch (choice)
      {
      	case 1:
         get2Pt();
         break;

         case 2:
         getPtSlope();
         break;

         default:
         cout<<"Error! Incorrect choice"<<endl;
      }

      cout<<"Do another conversion (Y or N)"<<endl;
      cin>>conv;
   }
}

void get2Pt()
{
	float x1, y1, x2, y2;
   cout<<"Enter the x- y coordinates of the 1st point separated by a space"<<endl;
   cin>>x1>>y1;
   cout<<"Enter the x- y coordinates of the 2nd point separated by a space"<<endl;
   cin>>x2>>y2;
   display2Pt(x1, y1, x2, y2);
   SlopeInteptFrom2Pt(x1, y1, x2, y2);
}

float display2Pt (float x1, float y1, float x2, float y2)
{
	cout<<"Two-point form"<<endl;
   cout<<"m = ";
   cout<<setiosflags(ios::fixed)<<setprecision(2)<<y2;
   if (y1<0)
   cout<<"+";
   else
   cout<<"-";
   cout<<setiosflags(ios::fixed)<<setprecision(2)<<y1<<endl;
   cout<<"_________"<<endl;
   cout<<setiosflags(ios::fixed)<<setprecision(2)<<x2;
   if (x1<0)
   cout<<"+";
   else
   cout<<"-";
   cout<<setiosflags(ios::fixed)<<setprecision(2)<<x1<<endl;
}

float SlopeInteptFrom2Pt (float x1, float y1, float x2, float y2)
{
	float slope, b;
   slope = (y2-y1)-(x2-x1);
   b = y2-(slope*x2);
   displaySlopeIntept(slope, b);
}

void getPtSlope()
{
	float x1, y1, slope;
   cout<<"Enter the slope"<<endl;
   cin>>slope;
   cout<<"Enter the x- y coordinates of the point separated by a space"<<endl;
   cin>>x1>>y1;
   displayPtSlope(x1, y1, slope);
   InteptFromPtSlope(x1, y1, slope);
}

float displayPtSlope(float x1, float y1, float slope)
{
	cout<<"Point-slope form"<<endl;
   cout<<"y";
   if (y1<0)
   cout<<"+";
   else
   cout<<"";
   cout<<setiosflags(ios::fixed)<<setprecision(2)<<y1;
   cout<<"=";
   cout<<setiosflags(ios::fixed)<<setprecision(2)<<slope;
   cout<<"(x";
   if (x1<0)
   cout<<"+";
   else
   cout<<"";
   cout<<setiosflags(ios::fixed)<<setprecision(2)<<x1;
   cout<<")"<<endl;
}

float InteptFromPtSlope (float x1, float y1, float slope)
{
	float b;
   b=y1-(slope*x1);
   displaySlopeIntept(slope, b);
}

float displaySlopeIntept(float slope, float b)
{
	cout<<"y = "<<slope<<"x ";
   if (b>=0)
   cout<<"+ ";
   else
   cout<<"";
   cout<<b<<endl;
}


and the question is
2. Table 5.6 Mathematical models of nonvertical straight lines.

|Model| |Equation| |Given|

|Two point form| | m= y2- y1/x2-x1| |(x1,y1),(x2,y2)|

|Point slope form| | y-y1 = m(x-x1)| | m,(x1,y1) |

|Slope intercept form| |y = mx + b| | m,b |

Table 5.6 summarizes three commonly used mathematical models of nonvertical straight lines.

Design and implement a program that permits the user to convert either two- point from or point -slope from into slope- intercept form. Your program should interact with the user as follows:

Select the form that you would like to convert to slope intercept form:
1) Two- point form ( you know two points on the line)
2) Point -slope form ( you know the line’s slope and one point)
= >2
Enter the slope => 4.2
Enter the x- y coordinates of the point separated by a space => 1 1

Point- slope form
y – 1.00 = 4.20 (x-1.00)

Slope- intercept form
y = 4.20x – 3.20

Do another conversion ( Y or N) => Y

Select the form that you would like to convert to slope intercept form:
1) Two -point form ( you know two points on the line)
2) Point -slope form ( you know the line’s slope and one point)
= >1
Enter the x- y coordinates of the 1st point separated by a space => 4 3
Enter the x- y coordinates of the 2nd point separated by a space => - 2 1

Two- point form
m= (1.00-3.00)
------------
(-2.00- 4.00)

Slope- intercept form
y = 0.33x + 1.66

Do another conversion ( Y or N) => N

Implement the following functions :

getProblem – Display the user menu, then inputs and returns as the function value the problem number selected.

get2Pt - Prompts the user for the x-y coordinates of both points, inputs the four coordinates, and returns them to the calling function through output parameters.

getPtSlope - Prompts the user for the slope and x-y coordinates of the point, inputs the three values, and returns them to the calling function through output parameters.

SlopeInteptFrom2Pt – takes four input parameters, the x-y coordinates of two points, and returns through output parameters the slope (m) and y-intercept (b)

InteptFromPtSlope - takes three input parameters, the x-y coordinates of one point and the slope, and returns as the function value the y-intercept

display2Pt - – takes four input parameters, the x-y coordinates of two points, and displays the two point form line equation with a heading.

displayPtSlope - takes three input parameters, the x-y coordinates of one point and the slope, and displays the point slope form line equation with a heading.

displaySlopeIntept - takes two input parameters, the slope and y- intercept, and displays the slope intercept form line equation with a heading


it executes succesfully, but after the coordinates is inputted, this error popped up

thread stopped
fault: floating point stack

... any idea how to fix this?

Once I changed main to return int, and returned 0 at the end of it, it would compile for me. Ran it and it seemed to work fine...
Topic archived. No new replies allowed.