|
How to
Jun 18, 2005 15:48:28 GMT
Post by Edwin on Jun 18, 2005 15:48:28 GMT
writing a program that allows a list of no more than 25 peronal computer vendors and their percent changes in market share for a particular year to be input and displays the information in two list "Gainers" and "Losers". Each list should be sorted by magnitude of the percent change. Data is to be stored in to arrays. Here are the top ten Vendors. Apple 2.8, AST 0.7, Bull/ZDS 0, Compaq -0.5, Everex 0.2, Gateway 2000 1.4, IBM -1.5, Packard Bell 0.3, Tandy 1.1, and Toshiba -0.02
I got it half right,
CLS INPUT "Enter number of Vendors: ", num DIM name$(1 TO num) DIM score$(1 TO num) REM Read the names and percentage into two arrays LET percent = num FOR vendor = 1 TO num INPUT "Enter name of Vendor: ", name$(vendor) INPUT "Enter percentage score: ", percent(vendor) LET total = percent(vendor) NEXT vendor CLS REM Display all names with percentage PRINT "GAINERS"; TAB(30); "LOSERS" PRINT PRINT "Vendor"; TAB 10); "Percentage";TAB (30); "Vendor"; TAB(40); "Percentage" PRINT FOR vendor = 1 TO num PRINT name$(vendor); TAB(10); percent(vendor) NEXT vendor END
that's what I came up with, but how do I seperate the positive vendor percentages from the negatives?
Thanks for your Time.
|
|
buff1
New Member
Posts: 3
|
How to
Jun 19, 2005 0:43:59 GMT
Post by buff1 on Jun 19, 2005 0:43:59 GMT
How about this. I substituted data statements so I wouldnt have to input the info each time CLS 'INPUT "Enter number of Vendors: ", num num = 10 DIM name$(1 TO num) DIM score$(1 TO num) REM Read the names and percentage into two arrays LET percent = num FOR vendor = 1 TO 10 'num 'INPUT "Enter name of Vendor: ", name$(vendor) 'INPUT "Enter percentage score: ", percent(vendor) READ name$(vendor), percent(vendor) IF LEN(name$(vendor)) > longest% THEN longest% = LEN(name$(vendor)) LET total = percent(vendor) NEXT vendor CLS REM Display all names with percentage LOCATE 1, 1 PRINT "GAINERS"; TAB(30); "LOSERS" PRINT PRINT "Vendor"; TAB(longest% + 1); "Percentage"; TAB(30); "Vendor"; TAB(30 + longest%); "Percentage" PRINT FOR vendor = 1 TO num IF percent(vendor) > 0 THEN leftrow% = leftrow% + 1 LOCATE leftrow% + 2, 1 PRINT name$(vendor); TAB(longest% + 10); : PRINT USING "###.##"; percent(vendor) END IF IF percent(vendor) <= 0 THEN rightrow% = rightrow% + 1 LOCATE rightrow% + 2, 30 PRINT name$(vendor); TAB(longest% + 40); : PRINT USING "###.##"; percent(vendor) END IF NEXT vendor END DATA Apple, 2.8 DATA AST, 0.7 DATA Bull/ZDS, 0 DATA Compaq, -.5 DATA Everex, .2 DATA Gateway 2000, 1.4 DATA IBM, -1.5 DATA Packard Bell, .3 DATA Tandy, 1.1 DATA Toshiba,-0.02
|
|
|
How to
Jun 19, 2005 1:35:11 GMT
Post by Edwin on Jun 19, 2005 1:35:11 GMT
Hey that's pretty good, I managed to work it out using IF's, but Your method is much more practical. As you can see I am just starting to learn programming, and Qbasic seems like a good place to start. I figure after a month or so I should have enough knowledge to move on to Visual basics, thanks for the help
|
|
|
How to
Jun 19, 2005 8:18:59 GMT
Post by Mikrondel on Jun 19, 2005 8:18:59 GMT
I suggest keeping away from Visual Basic, at least until you've had experience with a few completely different languages, such as C++, Perl, or PHP.
This would dramatically broaden your understanding and prevent you from getting "locked in" to a particular mindset when programming.
I'd further suggest you actually dig deep into QB for quite a bit longer, because if you're good enough to make a Pac-Man clone, or a Word Processor, or some other complicated project in QB on your own, then you'll have most of the programming concepts you'll ever need.
Have a weird analogy: Think of yourself as an alien learning to live among humans. If you just learn 20 words of English, then French won't be any easier to learn. But if you become a fluent English speaker, then you know how humans live, eat, what they like doing, and how they think about things, so you just need to learn different words without needing to learn about what they describe.
Of course, it's really up to you. Anyway, see you later.
Mikrondel
|
|
|
How to
Jun 19, 2005 12:50:35 GMT
Post by Edwin on Jun 19, 2005 12:50:35 GMT
Hey, I think I might take your advice, my whole idea is to get away from the standard routines that are force fed to us. So what do you think about Direct X, I have a how to program guide, but it requires basic knowlegde of C++?
|
|
|
How to
Jun 19, 2005 17:39:13 GMT
Post by Buff1 on Jun 19, 2005 17:39:13 GMT
You might consider PowerBasic for windows if you go to windows programming. Many of the statements that are familiar in qbasic/quickbasic are still available with PowerBasic for windows especially in their Console Compiler.
|
|