Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

beginner needs help with simple program 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I need to write a simple program for a swimming carnival, it doesn't have to be executable. it has to do the following:
INPUTS: Event name eg freestyle
Event distance eg 100m
Swimmers name
lane Number up to 8
Total time of each swimmer in min and sec
OUTPUTS:Name of event
Total time of all swimmers
Lane number and Winner of event
average time of all swimmers
list of results in order of finish
 
And...what have you written so far? It's better to have two heads to solve a problem from different angles than to have tunnel vision to a dead end.
 
tell us what you have so far. It looks like it will be a fairly easy program. Your could probably do it in less than 25 lines
 
As you can see from what I have writtn so far below that I have little understanding of QBASIC. Now you have finnished laughing; Please tell me what I need to make this work, please.

100 CLS
120 DEF FNAVG (TT) = TT\8
200 INPUT "THE EVENT NAME,(EG FREESTYLE)";EN$
300 INPUT "THE EVENT DISTANCE(EG 100M)";ED$
350 PRINT "TYPE COMPLETE OR complete AT SWIMMERS NAME? IF THERe ARE LESS THAN 8 SWMMERS"
375 WHILE SN$ <> &quot;COMPLETE&quot; OR SN$ <> &quot;complete&quot;
400 FOR LN - 1 TO 8
450 READ L$
460 PRINT &quot;ENTER DETAILS FOR &quot;; L$
500 IF SN$ = &quot;COMPLETE&quot; OR SN$ = &quot;complete&quot; THEN FLAG = 1
575 IF FLAG = 1 THEN GOTO 2100
700 INPUT &quot;RACE TIME IN MINS AND SECS&quot;; RT$
750 TT = TT + RT
800 NEXT LN
900 RESTORE 3000
2000 WEND
2100 PRINT &quot;THE WINNER OF THE &quot;;ED$;EN$;&quot;IS&quot;;SN$&quot;WITH A TIME OF RT$
2200 PRINT &quot;THE AVERAGE TIME FOE COMPEITORS WAS&quot;; FUNAVG(TT)
2250 PRINT &quot;THE FINISHING ORDER IS AS FOLLOWS&quot;
2260 REM ABOVE LINE IS SUPPOSED TO DISPLAY SWIMMER, TIME, LANE, FROM FASTEST TO SLOWEST
2300 INPUT &quot;WOULD YOU LIKE TO PRINT A COPY OF THE RESULTS Y OR N?&quot;;P$
2400 IF P$ = &quot;Y&quot; THEN LPRINT
2500 IF P$ = &quot;N&quot; THEN GOTO 100
3000 DATA LANE1,LANE2,LANE3,LANE4,LANE5,LANR6,LANE7,LANE8
4000 END



 
TO: mike_confused:
Firstly, no one is laughing at you. What tends to happen is that some &quot;Visitors&quot; come to this forum and expect someone else to do their homework while they themselves &quot;go out and with their friends&quot; then lay claim to doing the work themselves. And that's just wrong for several reasons. So, we normally ask for some 'proof' that they have at least started thinking about how to attack a problem. Sometimes, they just can't see the forest behind the trees, and sometimes it's just some guidance that is needed (and this appears to be your case.) After all, anyone who is a programmer started out just where you are now.


in response to: &quot;Please tell me what I need to make this work, please.&quot;

PROBLEM 1: No way to exit program...change SN$ to the appropriate variable

PROBLEM 2: You are asking the user for a string input (INPUT &quot;Mins and Secs. &quot;; RT$) and yet the next line your trying to add letters with numbers to give you a total average. You need to either ask for a number or (if you want to keep asking for a string) convert the string into numbers (see VAL in the help files).

PROBLEM 3: LPRINT will only print out a blank line since there is nothing there for QB to send to the printer.

Make it work 1: Modify line 500...use the UCASE$ command to simplify your IF/THEN operation. Type in UCASE$ in qb then place the cursor on it and press F1 for the help on that command.

Make it work 2: Modify line 500...you don't need to set FLAG=1 and then have another line that shoots it off to somewhere else. Just tell it to go there like &quot;IF xxx THEN GOTO xxxx&quot;. If you do change it, don't for get to erase line 575.

Make it work 3: To display the input in a specific order, you'll need to place the information that is entered into an Array. Or, you can do it the hard way by saving the inputed data to a file, then sort the file, then display the sorted data.


100 CLS
120 DEF FNAVG (TT) = TT \ 8
200 INPUT &quot;THE EVENT NAME,(EG FREESTYLE)&quot;; EN$
300 INPUT &quot;THE EVENT DISTANCE(EG 100M)&quot;; ED$
350 PRINT &quot;TYPE COMPLETE OR complete AT SWIMMERS NAME? IF THERe ARE LESS THAN 8 SWMMERS&quot;
375 WHILE [red]SN$ <> &quot;COMPLETE&quot; OR SN$ <> &quot;complete&quot;[/red]
400 FOR LN = 1 TO 8
450 READ L$
460 PRINT &quot;ENTER DETAILS FOR &quot;; L$
[red]500 IF SN$ = &quot;COMPLETE&quot; OR SN$ = &quot;complete&quot; THEN FLAG = 1
575 IF FLAG = 1 THEN GOTO 2100
700 INPUT &quot;RACE TIME IN MINS AND SECS&quot;; RT$
750 TT = TT + RT[/red]
800 NEXT LN
900 RESTORE 3000
2000 WEND
2100 PRINT &quot;THE WINNER OF THE &quot;; ED$; EN$; &quot;IS&quot;; SN$; &quot;WITH A TIME [red]OF RT$&quot;[/red]
2200 PRINT &quot;THE AVERAGE TIME FOE COMPEITORS WAS&quot;; FUNAVG(TT)
2250 PRINT &quot;THE FINISHING ORDER IS AS FOLLOWS&quot;
2260 REM ABOVE LINE IS SUPPOSED TO DISPLAY SWIMMER, TIME, LANE, FROM FASTEST TO SLOWEST
2300 INPUT &quot;WOULD YOU LIKE TO PRINT A COPY OF THE RESULTS Y OR N?&quot;; P$
2400 IF P$ = &quot;Y&quot; THEN [red]LPRINT[/red]
2500 IF P$ = &quot;N&quot; THEN GOTO 100
3000 DATA LANE1,LANE2,LANE3,LANE4,LANE5,LANR6,LANE7,LANE8
4000 END

It's better to have two heads to solve a problem from different angles than to have tunnel vision to a dead end.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top