|
Post by Kim on Jan 27, 2005 1:44:22 GMT
I just don't know where to begin.
Wtire a program that allows a list of no more than 25 personal comlputer vendors and their percent changes in market share for a particular year to be input and displays the information int two lists titled "gainers" and "losers." Each list should be sorted by teh magnitude of the percent change. Try your program on the 1991 data for the top US vendors given in table 1. You will need to store the data in an array to determine the number of gainers and losers.
Table 1: Top US personal computer Vendors (1991) company percent change
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 Toshiba -0.02
thanks for any help.
|
|
buff1
New Member
Posts: 3
|
Post by buff1 on Jan 28, 2005 6:12:57 GMT
I would suggest you look at Quickbasic/Qbasic help for Data statements and arrays. We do not do homework as is plainly shown. We will help with programs that you write.
|
|
|
Post by Kim on Jan 29, 2005 16:02:12 GMT
Thank you for the suggestion of where to look. Believe it or not, it's not my homework. It is an example that we should know for an upcoming test. I don't even know how to do the examples. I was hoping someone here could simply EXPLAIN it to me. I have read the book that was assigned and I just can't transfer the information into a word problem. I thought this would be the place that would allow me to ask questions. My question is...where do I start??
|
|
buff1
New Member
Posts: 3
|
Post by buff1 on Jan 29, 2005 16:40:00 GMT
Since most of these homework problems tend to use data statements, i would start with that. name,change then read in the data statements to an array.
Then finally sort by the percent change and print the results.
|
|
|
Post by remery35 on Jan 20, 2009 3:03:45 GMT
"Allows a list .... to be input". You start with this. First you must decide how QBASIC will store the list items. In the most basic terms, this is a 2 dimensional list. It can be represented on paper or screen as a 2 dimensional table. The equivilent in QBASIC is a 2-dimensional array.
One way to proceed (and this isn't the only way), is this example:
CONST MAXINDEX = 2
' Dimension a 2-dimensional array. This makes a storage location for the ' list within QBASIC. ' ' "0 TO 1" ' The first number can only take on two ' values, 0 or 1. I've decided that zero should mean the computer name, ' and 1 should mean the value change for that computer. ' ' "0 TO MAXINDEX" ' The second number can take on any one of 25 values, from 0 to 24 inclusive. ' (see line at the top to find where the "24" came from. Of course, you ' can just type "24" instead of "MAXINDEX", but that's a lot more work if you ' change your mind about how many computers in the list. ' DIM MyArray$(0 TO 1, 0 TO 2) ' The numbers are actually strings.
CLS 'clears the screen
FOR i% = 0 TO 2 ' The % means simple numbers having no fractions (integer). INPUT "Enter name of computer >", MyArray$(0, i%) ' user input INPUT " Enter the change >", MyArray$(1, i%) ' user input PRINT ' makes an empty row NEXT i%
' Optional print to screen to verify that the user input the data ' correctly. Helps with debugging the program, too. ' FOR i% = 0 TO 2 PRINT MyArray$(0, i%), , MyArray$(1, i%) NEXT i%
' You can copy a string, where the copy is actually a number like in this ' example using the first item in the list. ' MyNumber! = VAL(MyArray$(1, 0)) ' The number type for this number is ' is SINGLE. Like DOUBLE, it allows ' any mix of whole and fractional parts ' like 34.23 PRINT PRINT PRINT "============================================" PRINT "Demo on difference between string and number" PRINT "--------------------------------------------" PRINT PRINT "STRING", , "NUMBER" PRINT "========================================" PRINT MyArray$(1, 0), , MyNumber! PRINT PRINT "They look almost the same when printed. The spacing is different." PRINT "But the number, such as an INTEGER, SINGLE, LONG or DOUBLE is" PRINT "required for doing actual math like MyNumber! + 3" PRINT PRINT "MyNumber! + 3 = "; MyNumber! + 3 PRINT
|
|