decleration error

Write your question here.
what would i declare sloop and my x and y intersections as?
bool?
int?

#include <iostream>

using namespace std;

bool is_Line_Valid(double A, double B);
bool is_Line_Vertical(double B);
bool is_Line_Horizontal(double A);
bool Slope_Of_Line(double A, double B);



int main()

{

bool is_Valid, is_One_Vertical, is_One_Horizontal, is_Two_Vertical, is_Two_Horizontal, Slope;

double A1, B1, C1, A2, B2, C2;

// display intro for user
cout << "This program takes input values for two linear equations and then compares\n"

<< "their slopes and cordinates to determine if they are equal,\n"

<< " parallel, perpendicular, and their intersection if it exists.\n "

<< "The standard equation of a line is Ax+By=C\n"

// get coordinates of line 1

<< "Enter A, B, and C values for the first line\n";

cout << " A1 = ";

cin >> A1;

cout << " B1 = ";

cin >> B1;

cout << " C1 = ";

cin >> C1;

is_Valid = is_Line_Valid(A1, B1); // checking that a and b aren't 0


while (is_Valid == false) // get new coordinates if necessary

{
cout << "Invalid entry, A and B values must not equal zero, and they must\n";

cout << "enter A, B, and C, Values for the first line";

cout << endl << " A1 = ";

cin >> A1;

cout << " B1 = ";

cin >> B1;

cout << " C1 = ";

cin >> C1;

is_Valid = is_Line_Valid(A1, B1);

}
cout << is_Valid;

// check if line 1 is vertical
is_One_Vertical = is_Line_Vertical(B1);
if (is_One_Vertical == true)
cout << "line 1 is vertical" << endl;

// check if line 1 is horizontal
is_One_Horizontal = is_Line_Horizontal(A1);
if (is_One_Horizontal == true)
cout << "line 1 is horizontal" << endl;


// display line 1
cout << "Your first line is " << A1 << "x + " << B1 << "y = " << C1 << " . Enter A,B, and C values for the secound line.\n";

//work on getting 2nd line

cout << " A2 = ";

cin >> A2;

cout << endl << " B2 = ";

cin >> B2;

cout << endl << " C2 = ";

cin >> C2;

is_Valid = is_Line_Valid(A2, B2);

while (is_Valid == false)
{
cout << "Invalid entry, A and B values must not eual zero.\n";

cout << endl << " A2 = ";

cin >> A2;

cout << " B2 = ";

cin >> B2;

cout << " C2 = ";

cin >> C2;

}
cout << is_Valid;

is_Two_Vertical = is_Line_Vertical(B2);
cout << "line 2 is vertical" << is_Two_Vertical;

/* if (is_One_Vertical = FALSE)

{

slope1 = getSlope(A1, B1)

//endif

}

if (is_Two_Vertical = FALSE)

{

}

linear_Equality = [Slope1 = Slope2 and y intercepts equat to eachother]

if ((is_One_Vertical = FALSE)and(is_Two_Vertical = FALSE))

{

}

Slope2 = getSlope(A2, B2)

//endif

linear_Parallelism = ((A1 = A2) and(B1 = B2))

linear_Perpendicularity = (Slope1 = -1 / Slope2)

//endif */



/*

if ((is_One_Vertical == FALSE) AND(is_Two_Vertical = FALSE));

{

Linear_Perpendicularity = (slope1 = -1 / slope2);

//ENDIF

}

if ((linear_Equality = FALSE) AND(linear_Parallelism = FALSE)) AND((a2 != 0) AND(b1 !=

0));

{

xIntercept = CALL getX(A1, B1, C1, A2, B2, C2);

yINTERCEPT = cALL getY(xIntercept, A1, C1, B1);

//ENDIF

}

return is_Valid;

if is_One_Vertical = TRUE;

{

cout << "The line A1x + b1y = C2 is Vertical.";

//Endif

}

if is_One_Horizontal = TRUE;

{

cout << "The line A1x + b1y = C2 is Horizontal.";

//Endif

}

if is_Two_Vertical = True;

{

cout << "The line (A2)x + (B1)y = (C2) is Vertical.";

//endif

}

if is_Two_Horizontal = TRUE;

{

cout << "The line (A2)x + (B1)y = (C2) is Horizontal.";

//Endif

} */
}

//Functions

bool is_Line_Valid(double A, double B)

{

bool is_Valid;

is_Valid = !(A == 0 && B == 0);
return is_Valid;

}

bool is_Line_Horizontal(double A)

{

bool is_Horizontal;

if (A == 0)
is_Horizontal = true;
else
is_Horizontal = false;

return is_Horizontal;


}

bool is_Line_Vertical(double B)

{
bool is_Vertical;
is_Vertical = false;
if (B == 0)
is_Vertical = true;

return is_Vertical;

}

bool Slope_Of_Line(double A, double B)

{
bool slope;


Slope = (-A / B);

return Slope;

}

int GetX(double A1, double B1, double C1, double A2, double B2, double C2)

{

xIntersect = ((-B2((-A1 + C1) / B1)) + C2) / A2));

return xIntersect;

}

Int GetY(double A1, double C1, double B1) // (input parameters -Xintersect, A1,C1,B1)

{

yIntersect = ((-A((xintersect)+C1)) / B1));

return yIntesect;

}*/
Last edited on
its much simpler,
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
//Coordinate Geometry
#include <iostream>
using namespace std;

int main()
{
double A1, B1, C1, A2, B2, C2; // coordinates
// display intro for user
cout<< "This program takes input values for two linear equations \n"
	<< "and then calculates if they are equal, parallel, \n"
	<< "perpendicular, and their intersection if it exists.\n"
	<< "The standard equation of a line is Ax+By=C\n";

// get coordinates of line 1
	tryAgain1:
	cout << "Enter A, B, and C values for the First line\n";
	cin >> A1 >> B1 >> C1;
	if( A1==0 && B1==0 )
	{
		cout << "invalid line1. try again\n";
		goto tryAgain1;
	}
	
// get coordinates of line 2
	tryAgain2:
	cout << "Enter A, B, and C values for the Second line\n";
	cin >> A2 >> B2 >> C2;
	if( A2==0 && B2==0 )
	{
		cout << "invalid line2. try again\n";
		goto tryAgain2;
	}	

	if( A1/A2 == B1/B2 && A1/A2 == C1/C2)	
		cout << "they are same line\n";		
		
	if( A1/A2 == B1/B2 )	
		cout << "they are parallel\n";		
		
	if( A1*A2 + B1*B2 == 0 )
		cout << "they are perpendicular\n";
		
	double x, y;	
	if ( !(A1/B2==A2/B1) ) // not parallel
	{
		x= (B1*C2 - B2*C1) / (A1*B2 - A2*B1);		
		y= (C1*A2 - C2*A1) / (A1*B2 - A2*B1);
		
		cout << "their intersection point is (" << x << ", " << y << ") \n";
	}	
		
return 0;
}
Thanks, so much simpler than what i had.
Topic archived. No new replies allowed.