SgtMe 46 Veteran Poster Featured Poster

OK...that's where I was going wrong. What you would want to do is to feed the deposit from each month into a (double/float) array. Then, have a separate array of the same length detailing how long the corresponding deposit has been in the bank for (integer array). Then use a while/for loop to work through and calculate the interest for each deposit into another array. Then add up the totals at the end.

Are you sure that you need to get that amount of interest? The reason I asked you to use simple numbers is that it is no longer impossible to work out the true value, and will make it easier to determine errors in your code/logic.

SgtMe 46 Veteran Poster Featured Poster

Eeek...so the interest has to be calculated individually on each deposit?!

SgtMe 46 Veteran Poster Featured Poster

Great job with getting your post sorted! OK I've got it now! Sorry about that :/
I made a codez for you :)
It probably doesn't do exactly what you want it to do but check the logic between my code and yours.
I'd also recommend that you seperate up your main into 2 functions. Keep the user input in 1, and put the interest calculation logic in another, like my code below.

#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;

float getInterest(float deposit, float interest, int months)
{
    float monthInterest = (interest/12);
    float earnedInterest = (monthInterest*months)*deposit;
    return earnedInterest;
}

int main()
{
    float balance, deposit, interest;
    int months;
    cout<<"Enter balance (eg. £472.91):"<<endl;
    cin>>balance;
    cout<<"Enter deposit (eg. £22.01):"<<endl;
    cin>>deposit;
    cout<<"Enter annual interest rate (eg. 2.5%):"<<endl;
    cin>>interest;
    cout<<"Enter months until withdrawal (time to generate interest, int):"<<endl;
    cin>>months;
    cout<<"===================================="<<endl;
    
    float earnedInterest = getInterest(deposit, interest, months);
    cout<<"Balance             :           £"<<balance<<endl;
    cout<<"Deposit             :           £"<<deposit<<endl;
    cout<<"Interest            :           £"<<interest<<endl;
    cout<<"Months              :           £"<<months<<endl;
    cout<<"Earned interest     :           £"<<earnedInterest<<endl;
    cout<<"Total Balance       :           £"<<balance+earnedInterest<<endl;
    cout<<"=============================="<<endl;
    system("pause");
    
    return 0;
}

A couple more points with your code:

1. You don't need to set "0.0" as a value when you define a float/double.
eg.

double a = 0.0;
//is the same as
double a;

2. If you get rid of these, the top of your main function can become:

int numMonths;
float rate;
double balance, numBalance, totDeposited, totWithdrawn, mthlyInterRate, totInterest;

!!!EDIT!!! Sorry I forgot to put that you need to round the total balance …

SgtMe 46 Veteran Poster Featured Poster

OK. Your code now has a lots of random whitespace (tabs). Please edit your posts if the code looks like this. So the problem is that the interest doesn't calculate properly? Could you do one with much smaller numbers? It's easier to work with. I'm still confused as to what is wrong. So you want to calculate the amount of interest based on how many months it is in the bank for? Could you do a reworded demo with smaller numbers (much easier to grasp!), and give a deeper explanation.

SgtMe 46 Veteran Poster Featured Poster

Please use code tags. What is the problem you are having? Please give greater detail. Thanks :)

SgtMe 46 Veteran Poster Featured Poster

Do you have any compiler errors?

SgtMe 46 Veteran Poster Featured Poster

Sweet avatar Maxo!
I have only had a brief look at the game engine, but it looks fantastic. Also, I think that Blender is the better option, as it includes the ability to do everything (rigging, animating, sculpting, painting etc.). Plus, with a little Python knowledge, you could contribute your own plugin! Furthermore, other people's plugins can be installed very simply and are easy to obtain.

SgtMe 46 Veteran Poster Featured Poster
SgtMe 46 Veteran Poster Featured Poster

1. Stay here at DaniWeb! As you can see, we have a huge amount of dedicated members who love to contribute.
2. Have a look at sourceforge
3. You should have a decent understanding of Python and should be able to complete the task you sign up for. It really depends what the team lead is asking for.
4. I don't know if books are a good idea or not. I only used the official documentation for python when I was learning, and then just practise practise practise...
5. Just stick at it :)

SgtMe 46 Veteran Poster Featured Poster

OK so what is the current issue you are having?

SgtMe 46 Veteran Poster Featured Poster

Please mark the thread solved if your problem has been fixed.

SgtMe 46 Veteran Poster Featured Poster

I guess that these programs would offer up support eventually. Find a brand-new GUI or graphics module that is supported in 3.x This gives you the opportunity to learn how to use that module without wasting time.

SgtMe 46 Veteran Poster Featured Poster

You would want to read the string into an array. Split the string at each space, so you have individual words, and feed it into an array. Then use the "random" module to generate a number from 0 to the length of your array. Then, that integer it gives can be used to read a value from the array at that position. Ie, if it gave you 3, you would write, like:
print array[3]

SgtMe 46 Veteran Poster Featured Poster

So is your problem resolved now?

SgtMe 46 Veteran Poster Featured Poster

By this, it would suggest that either the variable has not yet been defined, or has not been defined in the same scope as where you are trying to call it (global scope, function scope etc.). Could you post the error and tell us the line which gives the error?

SgtMe 46 Veteran Poster Featured Poster

Not sure if you are getting the error (still getting back into C++ from a long spell in Python), but I think you need to define your "get_input" and "CheckLeapYear" functions before the main. Otherwise, you are calling something from the main that is not yet initialized. It also helps to keep the same type format for your function names. "get_input" and "CheckLeapYear" could instead become "GetInput" and "CheckLeapYear", or "get_input" or "check_leap_year".

I did a quick google for this problem and it seems that your logic for working out whether "x" is a leap year or not may be wrong. This is a line of C code I found:

if(year%400 ==0 || (year%100 != 0 && year%4 == 0))

Hope this helps you out :)

SgtMe 46 Veteran Poster Featured Poster

Also, if you have onboard graphics and it is turned on along with the graphics card, they may conflict. Go in the BIOS and check whether the onboard graphics are enabled.

SgtMe 46 Veteran Poster Featured Poster
print 'Input n'
n = int(raw_input())
data = []
i = 1
while i <= n:
	data.append(i)
	i+=2

print data
SgtMe 46 Veteran Poster Featured Poster

Not sure about the constructor thing. Basically, it's just a function that is called when you create an instance of the class. It doesn't really matter much deeper than that. Just use it to initialize all your variables/do other stuff that needs to be done when you create the class instance.
Can you please upvote my above post seeing as it helped you out :) Thanks.

SgtMe 46 Veteran Poster Featured Poster

With the code you have there (which you need to put in code tags next time :) ), is a good example of classes.

class Critter(object):
	def __init__(self):    					#you were missing a close bracket
		print "A new critter is born!"
	def talk(self):
		print "\nHi. I am an instance of class critter."       		#you were missing close quotes

#global scope!!!
crit1 = Critter()
crit2 = Critter()
crit1.talk()      							#"crit" was written incorrectly
crit2.talk()

Basically, the first line of code declares a class named "Critter". The second line is the __init__ function. This is called when you initialize an instance of the class, which will come up in a minute. The next line will just print that sentence to the console. As this is in the __init__ function, it will be printed when you initialize an instance of the class.

The "talk" function is basically a function that you can call that is associated with the class, that can be used with every instance of the class. This will again simply print a sentence to the console.

Now onto the main parts. Obviously, these are in the global scope, not in a main function. The first line in that section creates an instance of the "Critter" class, which is the value of the variable "crit1". This is pretty much the same as the next line. The next line calls the talk function from the instance of "Critter" assigned to the variable "crit1". The last line is pretty much the same, but …

SgtMe 46 Veteran Poster Featured Poster

I guess your not handling objects as such, but for doing accounts and database style things, I guess a struct would be slightly simpler than a class. Just my opinion though :)

SgtMe 46 Veteran Poster Featured Poster

I think what you need is structs.
Here is an example:

//usual intro stuff
#include <cstdlib>
#include <iostream>
using namespace std;

//create a struct for our account type
struct account{
        //this is where initialize the data variables for an account
        //acount number
	int number;
	//balance
	float amount;
	} ;

//usual main
int main(){
        //create an array of type "account"
        //size 20, for example
	account acc_list[20];
	//set the number and amount value for the first account
	//remember that account one is at position 0 in the array
	acc_list[0].number = 123456;
	acc_list[0].amount = 312.48;

        //repeat for the second acount (position 1 in the array)
	acc_list[1].number = 98765;
	acc_list[1].amount = 234.22;
	
	//print out to test
	//i only used the dollar sign because the pound sign won't
	//show properly...grrrrrrrr...
	cout<<"Account 1:           $"<<acc_list[0].amount<<endl;
	cout<<"Account 2:           $"<<acc_list[1].amount<<endl;
	
	//pause so we can see the result
	//only for windows/DOS
	system("pause");
	}

And here's a link to a tut an better explanation:
http://www.cplusplus.com/doc/tutorial/structures/

Please upvote/solved if this helped/solved your problem :)

SgtMe 46 Veteran Poster Featured Poster

The top line will confuse python. You should have (I think, from seeing another dictionary related post :/):

z = {'a':[1, 2, 3], 'b': 4, 'c': 5)

Not sure as I have barely used dictionaries, but I believe that one of the problems lies in line 4. You want it to tell you that 'a' is associated with 3. Are you sure it works both ways? Isn't it "3 is associated with 'a' ('a' being the 'parent')"? Is it reversable?

Also, KeyError '2', means that you are trying to search for the instance of '2' in the dictionary, which does not exist. It looks as though this lies within a module, but, taking your code as an example, though it is associated with 'a', it is not a dictionary object in itself.

SgtMe 46 Veteran Poster Featured Poster

I was just taking a look at compacting your code slightly, and I noticed something.

self.n = len(datalist)
data = datalist
length = len(datalist)
...
n = float(self.n)


Therefore

n = length

And then: ...(length/n)
This would be 1.


You can also change the function 'cdf_data' (including the above thing for the moment), to:

def cdf_data(self):   
	data = self.datalist
	plotdata =[]
        
	for i in range(len(data)):
		#got rid of: "n = float(self.n)"
		length = len(data)
		plotdata.append((data[0],length/float(self.n)))            #this line
		data.pop(0)
       
        return plotdata
SgtMe 46 Veteran Poster Featured Poster

Futhermore, why does findNode return none, and why do you need an if statement there to check whether it will return either nothing, or nothing? Therefore, findNode and actorNode will always be none, so your 'ifs' at lines 28 and 31 will always be none.

SgtMe 46 Veteran Poster Featured Poster

Well from having a look, it seems that you haven't defined x and y in all of your functions. I just had a quick look at the last one. You mention both 'x' and 'y', but neither have been declared in the function. You need to be able to pass 'x' and 'y' into other functions. You could do this with global variables (although they are discourage), or you could fit the whole thing in a class.

Global Variables
Classes (2.7 spec)

SgtMe 46 Veteran Poster Featured Poster

What line is the error on?

SgtMe 46 Veteran Poster Featured Poster

If I were you, I would have started out with Blender before using 3DSmax, seeing as max costs so much. Being a blender user, I would say blender, but that's a biased opinion. Tell you what: set yourself a task, like modeling a gun. Try to not to use a tutorial. See which program was easier for you and which model came out better.

darkagn commented: Excellent advice +4
SgtMe 46 Veteran Poster Featured Poster

I don't get what is wrong with using tabs. It makes sure everything is aligned evenly and is very quick compared to space bar...

SgtMe 46 Veteran Poster Featured Poster

A simple google search turned up this link:
http://code.google.com/p/jbullet-jme/wiki/InstallingBuilding

SgtMe 46 Veteran Poster Featured Poster

You need to edit the indents because there are some tabs and some spaces, and they are not all aligned. My advice would be to delete the whitespace on each line and then tab it out the appropriate number of times. Using tab is alot quicker and easier than using spaces.

SgtMe 46 Veteran Poster Featured Poster

Well it's the same strategy. You still need to count up with integers and convert to a string at the end. You should only need one loop for all that. Don't forget your ifs for all the columns as in my above post. If you want to keep it simple just have the loop with time.sleep(), but again you could sync it with real time for more accuracy.

SgtMe 46 Veteran Poster Featured Poster

Well start by allowing the user to input how much time they want to count down. Convert each section (hours, mins etc.) into an int so that you can count it down. Count down by 0.1 seconds (use ifs to find if one column equals 0, in which case it will become 9, and take 1 off the next column), convert the numbers back into a string, print, sleep (0.1). Repeat until all sections equal zero. Seeing as it takes a few milliseconds to execute each line of code, you may want to correlate your timer with real time. Consider using a separate module (maybe datetime?) to get the current time, and then you can synchronise your timer with what it should be to prevent it going out of step. This should only need to be done every few seconds.

SgtMe 46 Veteran Poster Featured Poster

Check out my post here for how you could expand on your program.
http://www.daniweb.com/forums/thread32007-24.html

SgtMe 46 Veteran Poster Featured Poster

Hmmm...now I'm thinking about it, it would be a hell of a lot easier to put all the GUI stuff in one file. I'd say that anything you had with your root (buttons, labels etc.) should all go in the one file. Then you could put your program logic in a different script. It really depends what your doing, but that is the easiest way.

SgtMe 46 Veteran Poster Featured Poster

Firstly:
Thanks for the effort you've put in.

Secondly:
I've made you a little program to demonstrate rounding, using floor() and ceil() [needs cmath, but you already have that]. Here's the code:

//Usual intro :P
#include <cstdlib>
#include <iostream>
#include <cmath>
using namespace std;

//Usual main...
int main(int argc, char *argv[])
{
    //a will be rounding result, x will be float to round
    int a;
    float x;
    
    //get input
    cout<<"Enter float for 'x'"<<endl;
    cin>>x;
    
    //if x + 0.5 is less than x rounded up, decimal place must be less than (.)5
    if ((x+0.5)<ceil(x)){a = floor(x);}
    else{a = ceil(x);}
    
    //print results and pause to view...
    cout<<"You entered:    "<<x<<endl;
    cout<<"Result:         "<<a<<endl;
    system("pause");
    
    //usual return. finito
    return 0;
}

Read through the comments to get the gist of what I'm doing. I have seen some older threads on various C++ forums where people do horrible, long, complicated thingamajigs. This is just a short simple program, and you only need a few lines of it anyway!

Example outputs:

Enter a float for 'x'
[eg.] 23.2
You entered: 23.2
Result: 23

Enter a float for 'x'
[eg.] 18.6758284
You entered: 18.6
Result: 19

Note:
You cannot change the precision with this method, so you can't round, say, 123.34934 to 123.35. There are other methods of doing this, but for a simple graphing program you should only need ints.

Hope this helps. Just reply in this thread if you need …

SgtMe 46 Veteran Poster Featured Poster

Am I getting this wrong or do you need to import ttk again in your new script? Also, root isn't defined in the second script. I would give you an example, but I gotta go now and I'll do it for you later :)

SgtMe 46 Veteran Poster Featured Poster

Oh yes it's perfectly possible! Make sure your external script is in the same folder as your main file, then just use "import example.py" (if that doesn't work remove the ".py"). Just make sure your variables can interact between the two scripts.

SgtMe 46 Veteran Poster Featured Poster

OK...I'll have a quick look.

1. If you want to print all the data:
eg.
cout<<"Student: "<<name<<"Class: "<<class<<"Average Score: "<<avg_score<<endl;

2. If you want to make it into a table, you could just use whitespace, or you can use ASCII to draw up a table, like using the (-), (_), (=), (|) and (¦) characters.

3. Not sure about this one. My recent experiences are that my programs crash if I try to use a pointer to an array ID that doesn't exist, ie:

int bob[3]
bob[3] = 234
//True IDs for bob array are: 0, 1, 2

Make sure that you have enough room in the array to enter the student data. Had a quick look over your code and think this may be the problem, but I could only have quck look.

Hope this helps :)

SgtMe 46 Veteran Poster Featured Poster

Whoops! Sorry prvnkmr449! Didn't notice you were writing a reply as well. Ah well :)
Also: even if it does count as a simple error, it's unavoidable. It's the same reason why people will get someone else to proof read a letter.

SgtMe 46 Veteran Poster Featured Poster

Firstly, you need to check your loop in the main function. Look where you write CalcAverage(). This needs to be inside a loop, so that you can run it for all students. Currently, it's just doing the calculations for one.
Secondly, yes you would could use a loop like that to print the data. In this situation, I would use variable i and increment each loop to print out the test scores. This would be best, seeing as it would support variable amounts of pupils.
Also, I would like to thank you on the fact that you have put in a great amount of effort before calling for help. You don't want to know how many times people have just demanded help :|

If you need anything else just ask :)

SgtMe 46 Veteran Poster Featured Poster

How about using the dos command rename? Consider this pseudocode (yes, I love pseudocode):

main function{
    print("enter old path")
    input>>old_path
    print("enter new path")
    input>>new_path
    system("pause")
    system("rename ", old_path, new_path)
    print("complete")
    }

I would give you a proper code, but I'm working back into console based C++, after spending 2 years in python. I want to learn more C++ than I originally did. Here's a couple of links:

http://www.computerhope.com/renamehl.htm
http://www.computing.net/answers/programming/dos-commands-in-c/9449.html
(on the second link, the second post should give you an idea)

Hope this helps :)

SgtMe 46 Veteran Poster Featured Poster

Checking out Kieran's code: works fine. Just a couple of points. When it asks for your body weight, is that kilograms or what? Good job guys :)

SgtMe 46 Veteran Poster Featured Poster

The question asked me, "Which OS do you think is best?" So I stated the ONE that I thought was best. Yes, it could be made muti-platform, but that was not the question -_-

SgtMe 46 Veteran Poster Featured Poster

Windows, because it used by more people, with better support.

SgtMe 46 Veteran Poster Featured Poster

What error do you get?

SgtMe 46 Veteran Poster Featured Poster

Why don't you make like a text-based shopping checkout program? You can have a main class filled with all the main functions, like a welcome, ouput priter etc.
Then you can have an object class. It can have variables like name, price, quantity, etc. Then you can make new objects using the base class.

SgtMe 46 Veteran Poster Featured Poster

I could be pretty much any language. Most likely this is just a list of strings. And no, you can't run a program from this. Seriously. Take more time to look at the code you want help with. Put in some effort. There is no way you can run this as a program. If that isn't obvious to you, you shouldn't be here.

SgtMe 46 Veteran Poster Featured Poster

C++ is definitely one of the top languages. It doesn't really matter what language you use, as long as you are good at it, and you can use it to create cross-platform games, if you want to distribute them or go commercial. From reading around, it seems that C# is the most frequently used these days, though you can be different.
Sorry but I can't really recommend you a book!

SgtMe 46 Veteran Poster Featured Poster

That would be better overal, sergb, but I feel that GothLolita should start off using text-files. You can use this to have test data for testing your program, and add full databse support later.