Hey1 fox so last weekend my friend asked if i could help her on her Comp Sci project, Little did she know im not a programming genius. So i've come to the one and only Daniweb for help... here's what she's supposed to do..

Write a C++ program by completing the following steps:
1.Write the heading for a bool function Equals that has two value float parameters, x and y.
2.Write the function prototype for the function in Step 1.
3.Write a body for the function in Step 1 that compares x and y, returning true if their difference is less than 0.0001, and false otherwise.
4.Write the main function that reads two float numbers from keyboard, call the function using these two floats as arguments, and display a message that includes the two numbers compared and the either they are equal or not based on the value returned by function.

All help is appreciated make me look good guys :D thanks.

Such a stupidly easy program.. I don't see why u wouldn't be able to make it.. took me 5 minutes max to make this.. Of course it can be optimized but I will not do this for you.. Secondly since I'm posting it below and I don't know if it's really your friend or for you, I will have to trust that you understand the code below or else u are just screwing yourself over.

@Mods:
If I get an infraction for this, there is no rule saying I cannot post code as long as I wrote it myself. As for spelling, there is no forum rules saying I must spell you instead of u. So whoever gave me an infraction just now for that, get a life.

#include <iostream>
#include <cmath>
#include <windows.h>

using namespace std;

float x, y;
bool Compare(float x, float y);

int main()
{
	cout<<"Enter a value for X: ";
	cin>> x;
	cin.ignore();
	
	if(cin.fail())
	{
		cout<<"Error. The value must be a number! \n\n";
		cin.clear();
		cin.get();
	}
	
	cout<<"Enter a value for Y: ";
	cin>> y;
	cin.ignore();
	
	if(cin.fail())
	{
		cout<<"Error. The value must be a number! \n\n";
		cin.clear();
		cin.get();
	}
	
	if(Compare(x, y) == true)
	{
		cout<<"The values  have a difference of at least 0.0001\n";
	}
	else
	{
		cout<<"The values do not have a difference of at least 0.0001\n";
	}
	
	cin.get();
	return 0;
}

bool Compare(float x, float y)
{
	float z = abs(x - y);
	
	if(z < 0.0001)
	{
		return true;
	}
	else
	{
		return false;
	}
}

I will have to trust that you understand the code below or else u are just screwing yourself over.

If it's really for his girlfriend then he's screwing her over...and not in a good way.

there is no rule saying I cannot post code as long as I wrote it myself

There's no rule against giving solutions away, but it's frowned upon as doing more harm to the OP than good. Sure, you helped someone get past an assignment, but they didn't learn jack in the process.

As for spelling, there is no forum rules saying I must spell you instead of u.

Actually, there are:

'Do post in full-sentence English'
'Do not write in all uppercase or use "leet", "txt" or "chatroom" speak'

Ignorance of the rules is no defense.

So whoever gave me an infraction just now for that, get a life.

Get a life, huh? Am I the only one who finds it funny that this is coming from someone who frequently posts on a programming forum? As far as having a life, I think a large majority of the world's population would say that none of us do. ;)

First and foremost i didn't mean to cause such a stir, secondly People Grow the F up... I came here trying to help My GF nothing more nothing less all i asked is for help. Anyway thanks for all who tried to help. And for the record i have taken Intro to CS, i understand most of the codding, i am just not good at building a program from scratch. And again thanks for all who tried to help.

I came here trying to help My GF nothing more nothing less

Assuming I'm interpreting the situation correctly, doing her work for her is the opposite of help; it's completely detrimental to her education. I'm sure your intentions are noble, but you're not doing what's best for your girlfriend.

And for the record i have taken Intro to CS, i understand most of the codding

I'm guessing this is Codding Studies. I am however curious if this is the successful harvesting of Pacific or Atlantic fish.;)

This article has been dead for over six months. Start a new discussion instead.