Added 91_Train port to MiniScript

This commit is contained in:
JoeStrout
2023-01-28 17:14:31 -07:00
parent 8440a1e30c
commit 60a6b290f4
2 changed files with 31 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
Conversion to [MiniScript](https://miniscript.org).

View File

@@ -0,0 +1,28 @@
// TRAIN
//
// Converted from BASIC to MiniScript by Ryushinaka and Joe Strout
while true
print "TRAIN"
print "CREATIVE COMPUTER MORRISTOWN, NEW JERSEY"
print ""
print "TIME - SPEED DISTANCE EXERCISE"
carSpeed = floor(25*rnd + 40)
difference = floor(15*rnd + 5)
trainSpeed = floor(19*rnd + 20)
print " A car traveling " + carSpeed + " MPH can make a certain trip in"
print difference + " hours less than a train traveling at " + trainSpeed + " MPH."
answer = input("How long does the trip take by car? ").val
carTime = difference*trainSpeed/(carSpeed-trainSpeed)
error = round(abs((carTime-answer)*100/answer))
if error < 5 then
print "GOOD! Answer within " + error + " PERCENT."
else
print "Sorry. You were off by " + floor(error) + " percent."
print "Correct answer is " + round(carTime, 1) + " hours."
end if
answer = input("Another problem (YES or NO)? ")
if not answer or answer[0].upper != "Y" then break
end while