Help with Qbasic homework

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
Egotistical EvilN
DCEmu User with No Life
DCEmu User with No Life
Posts: 3516
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Sun Nov 04, 2001 12:34 am
Location: Birmingham, Al
Has thanked: 0
Been thanked: 0
Contact:

Help with Qbasic homework

Post by Egotistical EvilN »

Description:"Design an algorythym that will read a series of integers. The first integer is special, as it indicates how many more integers will follow. Your algorythym is to calculate the sum and average of the integers, excluding the first integer, and display these values to the screen.


CLS
INPUT numberofvalues
count = 0
DO UNTIL numberofvalues = count
count 1 = count
LOOP

How can I make the amount of inputs I have be equal to numberofvalues, and then how do I add them together?
Image
Image
User avatar
toastman
Iron Fist of Justice
Iron Fist of Justice
Posts: 4933
Joined: Sat Nov 10, 2001 3:08 am
Location: New Orleans
Has thanked: 0
Been thanked: 0
Contact:

Re: Help with Qbasic homework

Post by toastman »

Egotistical EvilN wrote:Description:"Design an algorythym that will read a series of integers. The first integer is special, as it indicates how many more integers will follow. Your algorythym is to calculate the sum and average of the integers, excluding the first integer, and display these values to the screen.


CLS
INPUT numberofvalues
count = 0
DO UNTIL numberofvalues = count
count 1 = count
LOOP

How can I make the amount of inputs I have be equal to numberofvalues, and then how do I add them together?
You really can't be serious.
I can't believe anyone would be teaching QBasic.
No signature.
User avatar
henzenmann
Insane DCEmu
Insane DCEmu
Posts: 186
Joined: Wed Jul 12, 2006 4:58 pm
Has thanked: 0
Been thanked: 0
Contact:

Re: Help with Qbasic homework

Post by henzenmann »

toastman wrote:I can't believe anyone would be teaching QBasic.
It is still the best language to design algorythyms. :wink:
OneThirty8
Damn Dirty Ape
Damn Dirty Ape
Posts: 5031
Joined: Thu Nov 07, 2002 11:11 pm
Location: Saugerties, NY
Has thanked: 0
Been thanked: 0

Re: Help with Qbasic homework

Post by OneThirty8 »

Egotistical EvilN wrote:Description:"Design an algorythym that will read a series of integers. The first integer is special, as it indicates how many more integers will follow. Your algorythym is to calculate the sum and average of the integers, excluding the first integer, and display these values to the screen.


CLS
INPUT numberofvalues
count = 0
DO UNTIL numberofvalues = count
count 1 = count
LOOP

How can I make the amount of inputs I have be equal to numberofvalues, and then how do I add them together?
Um... Well, I think you could do something like this (take into account that I have never actually used Qbasic but I'll try to write BASICy pseudocode--also, the BASIC I use probably differs substantially, and I haven't used it in ages... so this may not work at all.)

Code: Select all

dim nov$
dim numberofvalues%
dim newnumber$
dim count%
dim runningtotal%
dim finalaverage%

INPUT nov
numberofvalues = val(nov)

count = 0
runningtotal = 0

WHILE count < numberofvalues

INPUT newnumber

runningtotal += val(newnumber)

count++
WEND

finalaverage = runningtotal/numberofvalues

Just a simple loop.
Egotistical EvilN
DCEmu User with No Life
DCEmu User with No Life
Posts: 3516
Joined: Sun Nov 04, 2001 12:34 am
Location: Birmingham, Al
Has thanked: 0
Been thanked: 0
Contact:

Re: Help with Qbasic homework

Post by Egotistical EvilN »

Fixed it. Done with all my assignments now. Thanks!
Image
Image
User avatar
Code-Red
DCEmu Ex-Admin
DCEmu Ex-Admin
Posts: 2601
Joined: Wed Nov 14, 2001 5:54 pm
Location: Ontario
Has thanked: 0
Been thanked: 0
Contact:

Re: Help with Qbasic homework

Post by Code-Red »

God I'm old. We learned BASIC in school long ago. This took me back a little.

Whats the difference between regular and Q?
User avatar
henzenmann
Insane DCEmu
Insane DCEmu
Posts: 186
Joined: Wed Jul 12, 2006 4:58 pm
Has thanked: 0
Been thanked: 0
Contact:

Re: Help with Qbasic homework

Post by henzenmann »

QBasic was included in later MS-DOS versions. It was a "lite"-version of Quickbasic, which in turn was the predecessor to Visual Basic. The biggest difference to "classic" basic interpreters was its nice IDE, and (as far as I remember) better support for structured programming and data types.

The fact that it has not been officially distributed in over ten years makes it seem strange that someone would actually teach/learn it these days ;-)
Post Reply