Final Help! C++ Class.

I have a final that's due today but I have no clue what to do. The assignment is in this pdf.

https://dl.dropboxusercontent.com/u/94570864/CSC.pdf

Any help would be greatly appreciated. I will give $30 to anyone who helps me complete this. I really don't want to fail this class.

UPDATED LINK: https://dl.dropboxusercontent.com/u/94570864/CSC%20Assignment.pdf

Thanks in advance!
Last edited on
Hi, the link appears to be broken.
Hey, I put up the updated link
For the love of god somebody please help. I can give $50 to anyone who can do it for me
Last edited on
This is an idea:

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
#include <iostream>

#define LAMBDA_0 5
#define THRESHOLD 2
#define BETA 0.1    // the step

using namespace std;

float net (float x) {
	/* This is the unknown net function.
	In order to run the program and have the
	expected behaviour, we can just use the identity
	function, i.e. a function which receives 'x' and
	returns 'x' */
	return x;
}


int main(int argc, char const *argv[])
{
	// the initial value
	const float L_0 = net (LAMBDA_0);

	float lambda = LAMBDA_0;
	float L = L_0;

	while (L > THRESHOLD) {
		cout << "Condition not met" << endl;
		lambda = lambda - BETA * L;
		cout << "New value of lambda = " << lambda << endl;
		L = net (lambda);
		cout << "New value of L = " << L << endl;
		cout << endl;
	}

	cout << "Terminated." << endl;


	return 0;
}


and this is the corresponding output:


Condition not met
New value of lambda = 4.5
New value of L = 4.5

Condition not met
New value of lambda = 4.05
New value of L = 4.05

Condition not met
New value of lambda = 3.645
New value of L = 3.645

Condition not met
New value of lambda = 3.2805
New value of L = 3.2805

Condition not met
New value of lambda = 2.95245
New value of L = 2.95245

Condition not met
New value of lambda = 2.65721
New value of L = 2.65721

Condition not met
New value of lambda = 2.39148
New value of L = 2.39148

Condition not met
New value of lambda = 2.15234
New value of L = 2.15234

Condition not met
New value of lambda = 1.9371
New value of L = 1.9371

Terminated.
Minomic, you are an absolute life saver. Could you just do me two more favors? Could you simply explain what you did there in simple english because I am gonna have to present this work. Second favor, what's your paypal e-mail??
First of all, I don't want to be paid! This is a forum where people should learn something, so it is a pleasure for me to help others.

Now that this is clear, I will explain the program. Or at least I will try my best, since English is not my mother tongue.
Last edited on
First of all I defined a net function. I know that the text says that the programmer does not know it, but in order to run the program we must have something we can use. The net function has to mimick the behaviour which is described in the text, so it has to be monotone increasing with the argument. This is the reason why I chose a simple net(x) = x. I could have used other functions too, like net(x) = x+1, net(x) = 2x, and so on.

Then I defined at the beginning of the file three quantities: the initial value of lambda (LAMBDA_0), the THRESHOLD (which is the value I want to reach) and BETA (which can be seen as a 'descending step' towards the threshold).

In the main I then set these initial condition with

1
2
	float lambda = LAMBDA_0;
	float L = L_0;


Now the while loop: while the condition is not met (which means 'while the value of L is still higher than the THRESHOLD I want to reach'), I calculate a new (lower) value of lambda by subtracting BETA*L. Once I have this new value, I give it to my net function to calculate the new value of L. At the following iteration, this new L is tested to verify whether it is still higher than the threshold or we can stop.

Any doubt?
Last edited on
This is a forum where people should learn something

Surely doing peoples' homework for them is the exact opposite of that? It's enabling them to avoid having to learn things.
Last edited on
I know, I think so too. But in many years of "forum attendance" (if this is the right way to say it), I learnt that sometimes what students need is something to start from. Hopefully they can become interested in what they see and start reading something on their own.

Anyway, let's be clear: no one can be forced to learn. They can be forced to study, but it is a much sadder thing. And another thing I really believe in is this one: we can't save everyone! :)

This means the following: if programming is something which will be required for one's job, then if you haven't studied it at school you will have to study it later. Otherwise you will be fired. On the other hand, if programming is something you have to do just at school and you don't need it for your life, then it's up to you to choose whether to spend some time on it as a hobby or not.

Once again: none of my business! ;)
Topic archived. No new replies allowed.