Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with my program
#1
Hey guys I have a program I have to make and have done almost all of it but I just need help with a last line

What I want to do is at the end of the results page before it tries to close the program, I want to display the drivers name, the clocked speed and what was the speed limit as in "60 in a 40", the points and then the fine, spaced out nicely
Here is my code


DIM average AS SINGLE
DIM clock AS INTEGER
DIM count1 AS INTEGER
DIM count2 AS INTEGER
DIM count3 AS INTEGER
DIM driver AS STRING
DIM disk AS STRING
DIM fine AS SINGLE
DIM fine1 AS SINGLE
DIM fine2 AS SINGLE
DIM fine3 AS SINGLE
DIM limit AS INTEGER
DIM overspeed AS INTEGER
DIM revenue AS SINGLE
DIM totpoints AS INTEGER
DIM totcount AS INTEGER
DIM points AS INTEGER
DIM points1 AS INTEGER
DIM points2 AS INTEGER
DIM points3 AS INTEGER
fine1 = 100!
fine2 = 275!
fine3 = 598!
points1 = 2
points2 = 4
points3 = 12

PRINT TAB(30); "Revenue calculator"
PRINT
ON ERROR GOTO fixes
OPEN "a:\records.dat" FOR APPEND AS #1
CLS
INPUT "What is the Driver's Name"; driver
DO WHILE driver <> "end"

PRINT
INPUT "What was the Driver's Clocked Speed in Km/h"; clock
PRINT
INPUT "What was the Posted Speed Limit in Km/h"; limit
overspeed = clock - limit
GOSUB fine
WRITE #1, driver, clock, fine, points
GOSUB printout
GOSUB Category
revenue = fine + revenue
totpoints = points + totpoints
PRINT
INPUT "What is the Driver's Name"; driver
LOOP
CLOSE #1
CLS
OPEN "a:\results.dat" FOR APPEND AS #2
GOSUB average
PRINT TAB(33); "Result screen"
PRINT
PRINT USING "&&&&"; "Category"; TAB(15); "³ Below 15km/h"; TAB(35); "³ 15km/h and 30 km/h"; TAB(65); "³ 30km/h+"
PRINT TAB(1); "No. of"
PRINT USING "& # # #"; "Drivers"; TAB(20); count1; TAB(40); count2; TAB(70); count3
PRINT
PRINT USING "& ##"; "The average points lost per offence"; TAB(58); average
PRINT
PRINT USING "& $$###.##"; "The Total Speeding Fine Revenue Collected"; TAB(55); revenue
CLOSE #2
END

fixes:
IF ERR = 53 THEN
PRINT "Insert Correct disk and press Enter"
INPUT "", disk
END IF
RESUME

average:
IF totpoints > 0 THEN
LET average = totpoints / totcount
END IF
RETURN

Category:
IF Category = 1 THEN
count1 = count1 + 1
ELSE
IF Category = 2 THEN
count2 = count2 + 1
ELSE
IF Category = 3 THEN
count3 = count3 + 1
END IF
END IF
END IF
RETURN

fine:
IF overspeed <= 0 THEN
fine = 0
Category = none
points = 0
PRINT
PRINT "No offense has been entered"
ELSE
IF overspeed <= 15 THEN
fine = fine1
Category = 1
points = points1
ELSE
IF overspeed > 15 AND overspeed <= 30 THEN
fine = fine2
Category = 2
points = points2
ELSE
IF overspeed > 30 THEN
fine = fine3
Category = 3
points = points3
END IF
END IF
END IF
END IF
RETURN

printout:
IF fine <> 0 THEN
totcount = totcount + 1
PRINT
PRINT "The offender was exceeding the speed limit by"; overspeed; "Km/h"
PRINT
PRINT USING "&&&&"; "Driver"; TAB(10); "Fine"; TAB(20); "Category"; TAB(35); "points loss"
PRINT
PRINT USING "& $$###.## # ##"; driver; TAB(8); fine; TAB(24); Category; TAB(38); points
END IF
RETURN
Reply
#2
Code:
PRINT "Driver name:"; driver$
PRINT "Speed: " + ltrim$(str$(clock)) + "km/h";
PRINT "out of a " + ltrim$(str$(limit)) + "km/h speed limit."
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#3
Hey mate every time I try to put that code in it keeps crashing mine
I might be putting it into the wrong place
Could you tell me where it needs to go?

Also
is it possible to lprint to a network printer?
When I try it just crashes
Reply
#4
It shouldn't crash your program anywhere
Reply
#5
After PRINT USING.

Maybe you have your file already open?

If you are trying to add to the file, use PRINT #1 instead..
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)