I'm new to C++.. and killing my brain to find this 1 error and cannot figure it out!!
I don't understand why square cannot equal true??? or false??
this is my 3rd program for my class to turn in!!
Any help would be appreciated!!
Eddy
//This program allow the user to enter dimensions in length and witdth
//of a rectangle in inches. The program then computes the perimeter in feet,
//the area in square feet and the length of the diagonal in feet.
// the program then determine if the rectangle is a square.
#include <iostream>
#include <cmath>
using namespace std;
//Function takes two integer parameters
//and gets values input from the keyboard
double get_perimeter(int& length, int& width);
//Function that gets the area
double get_area(int& length, int& width);
//Function that get the diagonal
double get_diagonal(int& length, int& width);
//Function determine square
bool determine_square(int& length, int& width);
int main()
{
int length, width;
double area, perimeter, diagonal;
bool square;
//get input from user
cout << "Enter length: ";
cin >> length;
cout << "Enter width: ";
cin >> width;
perimeter = get_perimeter (length, width);
area = get_area (length, width);
diagonal = get_diagonal (length, width);
square = determine_square (length, width);
cout <<"The perimeter is = "<< perimeter <<endl;
cout <<" The area is = "<< area <<endl;
cout <<" The diagonal length is = "<< diagonal <<endl;
if (square)
cout <<" This rectangle is a square.";
else
cout <<" This rectangle is not a square.";
return 0;
}
double get_perimeter (int& length, int& width)
{
double get_perimeter;
get_perimeter = ((2 * length) + (2 * width)) / 12.0;
return get_perimeter;
}
double get_area (int& length, int& width)
{
double get_area;
get_area = (length * width) / 144.0;
return get_area;
}
double get_diagonal (int& length, int& width)
{
double get_diagonal;
get_diagonal = sqrt (length * length + width * width) / 12.0;
return get_diagonal;
}
bool determine_square (int& length, int& width)
{
if (length == width)
square = true;
else
square = false;
return square;
}