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

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

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

SgtMe 46 Veteran Poster Featured Poster

That would be very difficult seeing as you have varied boundaries between grades. An easy way round it would be laying out percentage boundaries for each grade. Ie:

A* = 90%
A+ = 88%
A  = 86%
A- = 83%
B+ = 80%
etc.

Then calculate a percentage and work out which grade they got. This would take rounding because you most likely will end up with dividing to make a decimal, though you would have a lot of if statements. There's probably an easier way to do it that I haven't thought of...

SgtMe 46 Veteran Poster Featured Poster

Nice effort! I decided to rewrite your code to make a it bit shorter (it's a little long winded having lots of seperate functions for each bit of data). My code does look fairly long, but I have left comments, lots of whitespace, and a demo to prove that it works. I've commented the code so it's "self.explanatory" :)

#need for system commands
import os


#pet class
class Pet:

	#__init__ function
	#compressed setting all data into this functino
	def __init__(self, name, type, age):
		#take data from args and give to class variables
		self.name = name
		self.type = type
		self.age = age


	#function to return all the data
	def getData(self):
		#take from class variables
		return (self.name, self.type, self.age)


#main
def main():

	#request input
	print 'Enter name (string)'
	#input
	name = str(raw_input())

	#repeat
	print 'Enter type (string)'
	type = str(raw_input())

	#repeat with newline for whitespace
	print 'Enter age (int)', "\n"
	age = int(raw_input())

	#make new pet instance
	myPet = Pet(name, type, age),

	#get the data
	data = myPet.getData()

	#variable for while loop condition
	i=0;
	#loop
	while i < 3:
		#will print each bit of data on new line
		print data[i]
		#increment loop variable
		i+=1

	#pause so we can read the data
	os.system("pause")

#call the main
main()

Please upvote if it helped and solved if it fixed your problem :)

PS. Please include the error message in your post next time 'cos it helps us out a little. Thanks :)

SgtMe 46 Veteran Poster Featured Poster

Write a simple database program. Start off by inputting data through the console, then make a GUI (Tkinter or wxPython). Make completely your own system! Write/read data to/from text files.

Tips:
Start off with the vary basics. Just get a basic input output system going first. Don't worry about the program loop just yet. Just make sure that you can read and write data.
Keep your console GUI basic. It's only temporary, and, if there is too much clutter, it's hard to understand.
Use lots of loops so everything can be re-used. RECYCLE RECYCLE RECYCLE!!!

SgtMe 46 Veteran Poster Featured Poster

Duality - Slipknot

SgtMe 46 Veteran Poster Featured Poster

Post 1:
The return value will currently go no-where. If you want to write the return to the variable (luckyNumbers):

<type> luckyNumbers = spin_wheel();

Post 2:
If you want to repeat turns, then use a loop. Use, say, a while loop, to keep playing until the user presses a certain key or a variable is false or whatever.

SgtMe 46 Veteran Poster Featured Poster

You don't HAVE to return a bool if you don't have one declared. Change the type of the function and then change the type of variable that receives the return. You could just use "void" and not have any return if you don't need it.
(If people helped then upvote please :) )

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

What are the post count ranks?!
Can someone give me a complete list?

SgtMe 46 Veteran Poster Featured Poster

1.) This is not the python forum...how are python specialists going to find this?
2.) Show effort
3.) We don't know enough about your question to answer.

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

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

Please use code tags. Could you post the errors your are getting, and edit your first post using code tags. Then we can work through the errors. Once the program works, we can determine whether the logic is correct.

SgtMe 46 Veteran Poster Featured Poster

READ THE RULES!!! NO HELP UNLESS YOU SHOW EFFORt!!!
Besides which, we can't help you anyway, as we don't know your question specification, or what code you have already got, which we would need.

Nandomo commented: :) +1
VernonDozier commented: Yup! +11
tundra010 commented: Well said. +2
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

Just as an after-thought: type "lol limewire" into google and hit "I'm feeling lucky"... :L

Ancient Dragon commented: LOL :) +0
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

Oh OK sorry I misunderstood that bit (brain's-built-in-compiler-error-passed-as-silent).

SgtMe 46 Veteran Poster Featured Poster

Write simple theatre booking system. Start off by just using the console, then possibly moving on to GUI. Similarly, start off storing your data in text files, then move on to using proper database modules. Don't put yourself under too much pressure either! Just have a simple system that lets you book or unbook seats. Then add features such as: multiple performances and ticket types (Adult, Child, Discount). Also, you could make a console-GUI, where you use ASCII characters to create squares for seats, with the seat numbers in them. Then, use [A][C][D} to show which seats are taken and by who.

Tips:
Start simple. Don't have too many seats at the beginning. 3 rows of 5 max.
Sort out file storage. Data retrieval is important. Make sure you have a simple input output.
Use loops for loading the dater from a file. This means you can repeat many times.
Use loops elsewhere in your program to cut down on how much code you have.

bumsfeld commented: nice idea +7
e-papa commented: good +6
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

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

Google has plenty of those.

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

Here is one of the problems.
I copied your program into notepad (correct indentation) and made the two appropriate gif images. I save the problem as a python script and ran it. It opened, drew, and then closed. The reason for this is that you only run through one cycle of updating and drawing the screen. You need to make a 'while loop'. This keeps the statements inside the loop repeating (in the order that they are in) until the 'while' conditions are not met. Using 'while 1' will give you an infinite loop. Inside the loop, you have the statements you want to carry out, but at the end you need to pause your program for a few milliseconds so that it does not crash from running too quickly for your hardware.
Here is what you need to do. Fill the code in in the right places...it should be simple enough ;)

while 1:
	<Clear screen> #use screen.fill((RGB))
	<Update> #Call all update events for all sprites
	<Draw> # Call all draw events for all sprites and draw background.
	<Pause> # use pygame.time.wait(milliseconds). 10-20milliseconds should be good. Try more if not.

Drop the new code lines in place of the 'o.update' and 'o.draw' lines

Just ask if you need more help

SgtMe 46 Veteran Poster Featured Poster

I'm not really sure. I think C# would be a good language to use in the long run if you plan to become a paid games programmer, but then Flash is great for publicity as you said. I am trying to learn Actionscript 3 right now, but I'm having trouble finding a decent tutorial that's not made in Flash CS, because I use FlashDevelop. If you chose Flash, would you be prepared to buy Flash CS? If not, check out this:
http://www.daniweb.com/forums/thread280530.html

It might be best to start with Flash and acquire an audience, then maybe convert some of your flash games into XBLA games later.

Good luck in whatever you do.
Mark

nsutton commented: I love you. +1
SgtMe 46 Veteran Poster Featured Poster

It really depends on what you are doing. Is this game 2D? If so, you will want to use either of the following:

Python with the pyGame library (recommended!)
C++ with the allegro graphics library

I recommend python because the syntax is a lot easier. Also, pygame is a lot easier to understand than Allegro

For 3D games, you're probably best off using C++ or another derivative of C. This is because the main 3D libraries like GLUT, OpenGL and DirectX are almost 'native' to that language. You can use these in python, but it's harder, and you have to have other library wrappers installed. I was choose OpenGL and GLUT over DirectX, as it is a lot simpler.

Hope this helps you!
Mark

PS: Pygame has support for OpenGL bindings when using python, but again, python isn't the main language that OpenGL is used in.

bperiod commented: Well, good post. +1
SgtMe 46 Veteran Poster Featured Poster

Are you using 64-bit Python?
If so, this is likely to be the issue. Unfortunately, you will need to uninstall all the python modules you have and reinstall them on a 32-bit version of Python. Some modules such as Pygame and PyQt4 do not yet have support for 64-bit Python.

I am running 64-bit Windows 7 Home Premium with Python 2.6.4, and since I did this for pyGame, I have had no further issues.

SgtMe 46 Veteran Poster Featured Poster

Tkinter. It have you noticed how the notepad buttons look better? That's because of Windows 7, not a new GUI.

SgtMe 46 Veteran Poster Featured Poster

I have some basic Tkinter tutorials on youtube if anyone wants to look.
http://www.youtube.com/pyProgrammer96

SgtMe 46 Veteran Poster Featured Poster

well have you started? what code have you got already? what are you stuck on? we wont help you if you get the answers 'no' and 'none' to the first questions.
Sorry to be of no help, but it's a rule.

SgtMe 46 Veteran Poster Featured Poster

I'm stating my opinion in short form thank you.

SgtMe 46 Veteran Poster Featured Poster

Use Dev-C++ cos its best for installing new libs.

SgtMe 46 Veteran Poster Featured Poster

Have you started?
If so, can we see your code so far?
If not, well don't wait for a reply - start programming now and you might make it. No-one here will help you. It's a rule.

The Queen of DaniWeb:
'We only give homework help to those who show effort.'

SgtMe 46 Veteran Poster Featured Poster

cppgameprogramming.com ( allegro )
cplusplus.com ( general C++ )
codeguru.com ( another forum though this one is better :} )

zobadof commented: Thanks! +0