Clan x86

Technical (Development, Security, etc.) => General Programming => Topic started by: skip on November 15, 2006, 12:42:45 pm

Title: Help!
Post by: skip on November 15, 2006, 12:42:45 pm
with QBasic.

"Assume that your money is invested in an account that draws interest compounded annually. That is, at the end of each year the amount invested (principle) is multiplied by the interest rate, and that interest amount is added to the principle. Write a program, using a FOR.. NEXT LOOP, that will get the amount invested, the interest rate, and number of years from the keyboard (INPUT statements). It should then produce a printout showing how much money will be on hand at the end of EACH year."

So far, this is what I have:
Quote
INPUT "Enter amount to invest: ", moneyinvested
INPUT "Enter the interest rate: ", interestrate
INPUT "Enter number of years to invest: ", years

FOR X = years to 1 STEP -1
           totalmoney = (moneyinvested * interestrate) + moneyinvested
NEXT X

Any help would be appreciated!  :)
Title: Re: Help!
Post by: abc on November 15, 2006, 12:48:52 pm
Uhh.. I don't think anyone here *uses* or *knows* QBasic.... :P
Title: Re: Help!
Post by: Miamiandy on November 15, 2006, 01:13:00 pm
I know it a little though I haven't used it in ages. Also, I have a friend who just took a programming class online that for some reason programmed in QBASIC. 

In the loop add "PRINT totalmoney" I think that is what is need. I'll check when I get home and have the program, I think QBASIC is on my computer somewhere. QBASIC is a language that I haven't used in a long time.
Title: Re: Help!
Post by: rabbit on November 15, 2006, 01:46:51 pm
I know QBASIC.

Basically you want a /PRINT "You have ", totalmoney/ in there
Title: Re: Help!
Post by: abc on November 15, 2006, 01:51:17 pm
Ah, Why would you atempt to learn QBasic anyways?
Title: Re: Help!
Post by: Sidoh on November 15, 2006, 02:04:25 pm
Ah, Why would you atempt to learn QBasic anyways?

Probably because he took a class where it was taught.  I can't think of any other reason...
Title: Re: Help!
Post by: skip on November 15, 2006, 07:01:14 pm
Ah, Why would you atempt to learn QBasic anyways?

Probably because he took a class where it was taught.  I can't think of any other reason...

Exactly.

@rabbit/Miamiandy: The program is far from finished than by just adding a simple PRINT statement. Re-read the instructions in my first post.  :P
Title: Re: Help!
Post by: Miamiandy on November 15, 2006, 07:11:29 pm
You also need to another to plug total money back into the equation for every subsequent year following the first one.
Title: Re: Help!
Post by: Joe on November 16, 2006, 06:26:04 pm
Ah, Why would you atempt to learn QBasic anyways?

Rabbit was around back in the days of QBASIC, I think. In fact, I remember back when Windows 95 was bleeding edge, Windows 3.1 was commonplace, and Visual Basic 3 was the thing to do.
Title: Re: Help!
Post by: Miamiandy on November 16, 2006, 06:51:32 pm
The first language I learned was QBASIC and at the time I could use it quite well. Although, this was 8 or so years ago. I was in 3rd or 4th grade at the time I think.
Title: Re: Help!
Post by: Warrior on November 16, 2006, 07:03:56 pm
Ah, Why would you atempt to learn QBasic anyways?

Rabbit was around back in the days of QBASIC, I think. In fact, I remember back when Windows 95 was bleeding edge, Windows 3.1 was commonplace, and Visual Basic 3 was the thing to do.

Arn't you like 15? So..you were programming at the age of like 8?
Title: Re: Help!
Post by: Miamiandy on November 16, 2006, 07:04:52 pm
17 years old. I definitely was doing QBASIC in 4th and 5th. Nothing else till 7th though.
Title: Re: Help!
Post by: Warrior on November 16, 2006, 07:33:21 pm
17 years old. I definitely was doing QBASIC in 4th and 5th. Nothing else till 7th though.

Not you, I quoted Joe for a reason :P
Title: Re: Help!
Post by: Miamiandy on November 16, 2006, 07:34:23 pm
Oops, sorry.
Title: Re: Help!
Post by: rabbit on November 16, 2006, 10:01:31 pm
I first learned to program QBASIC and Batch on Windows 3.11/MSDOS and (pwn) for OS/2 :P
Title: Re: Help!
Post by: Ender on November 17, 2006, 05:21:20 pm
I always feel that when people ask for help on homework it forces the forum members into a moral dilemma. The people who assist never know for sure whether the teacher allows it or whether the person asking for help is honest.

Anyways, hints...

That's not how compound interest works. It semantically resembles it but is conceptually stranded. If you have any questions about compound interest, post in the math forum ^_^.
Title: Re: Help!
Post by: Ender on November 17, 2006, 05:27:19 pm
mm, and another hint

Your code doesn't make sense. You're reassigning a variable to a constant times a constant plus a constant each iteration of the for-loop.
Title: Re: Help!
Post by: Ender on November 17, 2006, 05:28:14 pm
Uhh.. I don't think anyone here *uses* or *knows* QBasic.... :P

How does that prevent people from helping?

Woops, triple posted =\ Mods feel free to merge these...
Title: Re: Help!
Post by: Blaze on November 21, 2006, 01:59:03 am
Code: [Select]
CLS

'By Ian Fox
'November 21, 2006
'Some guys homework

DIM dblCurrentBalance AS DOUBLE         'The current balance
DIM sinInterestRate AS SINGLE           'The interest rate
DIM intInvestmentLength AS INTEGER      'How many years they are investing
DIM i AS INTEGER                        'A temporary variable used for FOR LOOPing


DO
        INPUT "How much money would you like to invest"; dblCurrentBalance
        PRINT "You must enter a value greater then `0'."
LOOP UNTIL dblCurrentBalance > 0

CLS

DO
        INPUT "What is the Interest rate on your investment"; sinInterestRate

        PRINT "The interest rate must not be a negative number."
LOOP UNTIL sinInterestRate >= 0

CLS

DO
        INPUT "How many full years would you like to invest"; intInvestmentLength
        PRINT "The amount of years must be positive."
LOOP UNTIL intInvestmentLength > 0

CLS

'Okay, we have all of our values and hopefully due to some basic
'error checking, everything should turn out correctly.. or at least
'it should make sense.


PRINT "You start out with $"; dblCurrentBalance; "invested at an interest rate of "; sinInterestRate; "%."

sinInterestRate = sinInterestRate * .01 'Make the interest rate a decimal for multiplying

FOR i = 1 TO intInvestmentLength
        dblCurrentBalance = dblCurrentBalance + (sinInterestRate * dblCurrentBalance)
        PRINT USING "After year ### you have $ ###########.## invested."; i; dblCurrentBalance
NEXT i

Meh, I think I shouldn't have wrote this... but I was bored.
Title: Re: Help!
Post by: Sidoh on November 21, 2006, 03:01:26 am
Now how's he supposed to learn anything? >:(
Title: Re: Help!
Post by: Ender on November 22, 2006, 02:53:15 pm
Yes, that was a hindrance to his learning. And although one may plausibly argue that such a transgression causes insignificant disturbance to the educational system, it is more a matter of morality. Just like downloading music illegally.

*braces himself for angry responses*
Title: Re: Help!
Post by: Sidoh on November 22, 2006, 02:56:07 pm
Yes, that was a hindrance to his learning. And although one may plausibly argue that such a transgression causes insignificant disturbance to the educational system, it is more a matter of morality. Just like downloading music illegally.

*braces himself for angry responses*

Go fuck the RIAA.  We don't care about your stance on downloading music. 

Illegally downloading music has nothing to do with posting code for a homework assignment.  You just want attention.
Title: Re: Help!
Post by: Ender on November 22, 2006, 03:47:42 pm
My favorite artists, Sigur Ros and Explosions in the Sky, distribute their music freely on their sites. Ergo my taste of music is superior.
Title: Re: Help!
Post by: Sidoh on November 22, 2006, 03:55:08 pm
My favorite artists, Sigur Ros and Explosions in the Sky, distribute their music freely on their sites. Ergo my taste of music is superior.

So does Heathen.  I'm pretty sure you could find places that allow you to download their composures of Vivaldi, Bach, Mozart and Beethoven legally, therefore, you suck at analyzing your taste in music. ;)
Title: Re: Help!
Post by: Blaze on November 22, 2006, 04:19:13 pm
Feel free to delete it, I originally was just going to do it but not post it, but then I changed my mind.
Title: Re: Help!
Post by: AntiVirus on November 25, 2006, 10:38:29 pm
A lot of my indie bands post their music on the Internet for free downloads.
Title: Re: Help!
Post by: Joe on November 26, 2006, 05:41:34 am
Ah, Why would you atempt to learn QBasic anyways?

Rabbit was around back in the days of QBASIC, I think. In fact, I remember back when Windows 95 was bleeding edge, Windows 3.1 was commonplace, and Visual Basic 3 was the thing to do.

Arn't you like 15? So..you were programming at the age of like 8?

I'm sixteen. I started programming basic AppleScript back in like.. third grade. So yeah, I was programming at the age of eight. From there I stepped up to some Commodore / Apple II BASIC, which I've completely forgotten. Eventually I moved at the beginning of a summer vacation and found myself in my room, programming, 24/7, becoming the God of VB.
Title: Re: Help!
Post by: MyndFyre on November 26, 2006, 05:43:54 am
I'm sixteen. I started programming basic AppleScript back in like.. third grade. So yeah, I was programming at the age of eight. From there I stepped up to some Commodore / Apple II BASIC, which I've completely forgotten. Eventually I moved at the beginning of a summer vacation and found myself in my room, programming, 24/7, becoming the God of VB.

Joe, there are a lot of things I would call you.  God of VB is not on that list.
Title: Re: Help!
Post by: Blaze on November 26, 2006, 11:15:09 pm
I'm sixteen. I started programming basic AppleScript back in like.. third grade. So yeah, I was programming at the age of eight. From there I stepped up to some Commodore / Apple II BASIC, which I've completely forgotten. Eventually I moved at the beginning of a summer vacation and found myself in my room, programming, 24/7, becoming the God of VB.

Joe, there are a lot of things I would call you.  God of VB is not on that list.

I love you.
Title: Re: Help!
Post by: Joe on November 28, 2006, 05:09:58 pm
I'm sixteen. I started programming basic AppleScript back in like.. third grade. So yeah, I was programming at the age of eight. From there I stepped up to some Commodore / Apple II BASIC, which I've completely forgotten. Eventually I moved at the beginning of a summer vacation and found myself in my room, programming, 24/7, becoming the God of VB.

Joe, there are a lot of things I would call you.  God of VB is not on that list.

Compared to some people though, I'm rather good, no? :P
Title: Re: Help!
Post by: Sidoh on November 28, 2006, 05:12:05 pm
I'm pretty good at roller blading, but I don't think I'm the god of it.
Title: Re: Help!
Post by: Rule on November 28, 2006, 05:32:57 pm
Yes, that was a hindrance to his learning. And although one may plausibly argue that such a transgression causes insignificant disturbance to the educational system, it is more a matter of morality.

Though I tend to agree with you to an exent, from what I've seen, I think you've been brainwashed by "the educational system" into taking these things a bit too seriously.  In the big picture, does it really matter that much?  (Hint: this is a rhetorical question, and the obvious answer is no).
Title: Re: Help!
Post by: rabbit on November 28, 2006, 08:32:05 pm
Some people like retarded 5 year olds, or people who can read?
Title: Re: Help!
Post by: d&q on November 28, 2006, 10:10:18 pm
Yes, that was a hindrance to his learning. And although one may plausibly argue that such a transgression causes insignificant disturbance to the educational system, it is more a matter of morality.

Though I tend to agree with you to an exent, from what I've seen, I think you've been brainwashed by "the educational system" into taking these things a bit too seriously.  In the big picture, does it really matter that much?  (Hint: this is a rhetorical question, and the obvious answer is no).


Depends if you're Nigerian or not.
Title: Re: Help!
Post by: MyndFyre on November 29, 2006, 05:05:26 am
Compared to some people though, I'm rather good, no? :P
That's like saying a penguin is good at swimming compared to other birds. :P
Title: Re: Help!
Post by: iago on November 29, 2006, 02:49:43 pm
Compared to some people though, I'm rather good, no? :P
That's not something to be proud of.
Title: Re: Help!
Post by: Joe on November 30, 2006, 12:48:10 am
Compared to some people though, I'm rather good, no? :P
That's like saying a penguin is good at swimming compared to other birds. :P

You picked a bad example, because you know that out out of one iago's know that penguins are the God's of everything.