SgtMe 46 Veteran Poster Featured Poster

vampire -> garlic ;)

SgtMe 46 Veteran Poster Featured Poster

612

SgtMe 46 Veteran Poster Featured Poster

What is the wrong result you are getting? Please tell us as much as you can about what is wrong and we will be able to help you more easily.

PS. To mark as solved: just above the reply box at the bottom of the thread will be a bit about the thread being solved. It's easy enough to do when you look in the right place :)

SgtMe 46 Veteran Poster Featured Poster

If you want some practice exercises, head over to this thread:
http://www.daniweb.com/forums/thread32007.html
It's for python beginner projects, but you can use the same ideas in C++ as well :)

SgtMe 46 Veteran Poster Featured Poster

So you want to read verts from a file and write it in your own format? You just need to be able to read a line from a file, delete any un-needed characters and split the string up into three parts. Then you can convert them to int and make a list of these. Just do google searches for the above bits and pieces. Should turn something up.

SgtMe 46 Veteran Poster Featured Poster

Please mark as solved.

SgtMe 46 Veteran Poster Featured Poster

Hi I'm Mark and I'm a...

  • Music Geek
  • Music Geek
  • Music Geek
SgtMe 46 Veteran Poster Featured Poster

Thanks :) I shall be back later

SgtMe 46 Veteran Poster Featured Poster

OK. Sorry I can't write out much more code for you 'cos I've got a 3D modeling project to sort out. Here are some links to get you help on this.
Arrays
Time Value Of Money (Just take a glance)

Please can you upvote my posts seeing as I have helped you out :)

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

IT discussion forum anywhere on the

SgtMe 46 Veteran Poster Featured Poster

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

SgtMe 46 Veteran Poster Featured Poster

Is this thread solved? If so, please mark as. Thanks :)

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

mortality -> immortality

SgtMe 46 Veteran Poster Featured Poster

whay! A sane person ;)
616

SgtMe 46 Veteran Poster Featured Poster

that has been played by many

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

To create a new screen, you could just manipulate what is on the screen already. You could delete all the objects from the current screen, and then add the new objects of the next scene. There is probably a better way to do it as that would be a little long winded.

You have several errors in your code. Firstly, you cannot destroy "root" in your c2 class, as, in the class scope, it does not exist. Also, you haven't defined the classes properly with their "__init__" functions. It should be:

def __init__(self):

Also, you are trying to pass "root1" (a Tkinter program instance), to class "c1", which takes no arguments, and has no attribute of "Tk".

The last major error is that you have

if user:

but "user" is not defined. You need to define a variable before you use it as a conditional variable.

Here's something for you to have a look at.

import os
from Tkinter import *

class C1:
	def __init__(self):
		self.root = Tk()
		print 'Root 1'
		if true:
			root.destroy()
			C2()

class C2:
	def __init__(self):
		self.root1 = Tk()
		print 'Root 2'
		os.system("pause")


C1()

I'm still not entirely sure what you are trying to do with the above code. Have a look at this on classes.

http://docs.python.org/tutorial/classes.html

Please upvote it this helped and mark the thread as solved if I solved your problem.

SgtMe 46 Veteran Poster Featured Poster

What are you trying to get the monthly average of? Can you explain your problem a bit better? It's unclear what problem you are having.

SgtMe 46 Veteran Poster Featured Poster

Yeah sorry about that! I must have done something funny somewhere 'cos it worked fine at one point. I must have changed something before I posted it! Sorry :/ Please could you upvote my post (the one with the code) seeing as it helped you out and mark the thread as solved. Thanks :)

SgtMe 46 Veteran Poster Featured Poster

Code tags please :) I can't read your code like that properly with all the whitespace removed.

SgtMe 46 Veteran Poster Featured Poster

"Hero" Skillet :D:D:D:D:D

SgtMe 46 Veteran Poster Featured Poster

tragedy -> death

SgtMe 46 Veteran Poster Featured Poster

one of the mooons of

SgtMe 46 Veteran Poster Featured Poster

I used type in my code and I didn't get any errors and it worked fine :/ I have 2.6.4 so it may be later/earlier implementation. Yeah I think Tonyjv's code is better :L

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
SgtMe 46 Veteran Poster Featured Poster

seinfeld -> comedy

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

laughter -> funny

SgtMe 46 Veteran Poster Featured Poster

612 *nervous* *nice putting down by 1 jib ;) *

SgtMe 46 Veteran Poster Featured Poster

contagious -> ill

SgtMe 46 Veteran Poster Featured Poster

to be found

SgtMe 46 Veteran Poster Featured Poster

Duality - Slipknot

SgtMe 46 Veteran Poster Featured Poster

Here's a page on checking for a prime number:
http://www.wikihow.com/Check-if-a-Number-Is-Prime

SgtMe 46 Veteran Poster Featured Poster

Do you have any compiler errors?

SgtMe 46 Veteran Poster Featured Poster

by the largely

SgtMe 46 Veteran Poster Featured Poster

swine flu -> bird flu

SgtMe 46 Veteran Poster Featured Poster

615 :/

SgtMe 46 Veteran Poster Featured Poster

What problems are you having so far?

SgtMe 46 Veteran Poster Featured Poster

Do you really need an entire book? Take a look at this website. Read through the code and the explanations and then make your own demo of structs. It's unbelievably simple.

http://www.cplusplus.com/doc/tutorial/structures/

SgtMe 46 Veteran Poster Featured Poster

Catastrophy -> Death

SgtMe 46 Veteran Poster Featured Poster

diamond in the

SgtMe 46 Veteran Poster Featured Poster

LOL Achooooooooooo- 621...

SgtMe 46 Veteran Poster Featured Poster

Yup. Why is your while loop inside a for loop? Surely this would mean that each time your while loop is not accepted the for loop will increase by one until five where it will not run?

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

"No no no no...It can't possibly be true!"
"What can' be true?"