Added MiniScript version of 22_Change.

This commit is contained in:
JoeStrout
2023-07-25 20:59:51 -07:00
parent 6a611c04d7
commit f98fffc19f
2 changed files with 76 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
Conversion to [MiniScript](https://miniscript.org).
Ways to play:
0. Try-It! Page:
Go to https://miniscript.org/tryit/, clear the sample code from the code editor, and paste in the contents of change.ms. Then click the "Run Script" button. Program output (and input) will appear in the green-on-black terminal display to the right of or below the code editor.
1. Command-Line MiniScript:
Download for your system from https://miniscript.org/cmdline/, install, and then run the program with a command such as:
miniscript change.ms
2. Mini Micro:
Download Mini Micro from https://miniscript.org/MiniMicro/, launch, and then click the top disk slot and chose "Mount Folder..." Select the folder containing the BASIC program. Then, at the Mini Micro command prompt, enter:
load "change"
run

View File

@@ -0,0 +1,57 @@
print " "*33 + "Change"
print " "*15 + "Creative Computing Morristown, New Jersey"
print; print; print
print "I, your friendly microcomputer, will determine"
print "the correct change for items costing up to $100."
print; print
while true
itemCost = input("Cost of item? ").val
if itemCost == 0 then break
payment = input("Amount of payment? ").val
change = payment - itemCost
if change < 0 then
print "Sorry, you have short-changed me $" + (itemCost - payment)
continue
else if change == 0 then
print "Correct amount, thank you."
continue
end if
print "Your change, $" + change
dollars = floor(change/10)
if dollars then print dollars + " ten dollar bill(s)"
change -= dollars * 10
fivers = floor(change/5)
if fivers then print fivers + " five dollar bill(s)"
change -= fivers * 5
ones = floor(change)
if ones then print ones + " one dollar bill(s)"
change -= ones
change *= 100 // (now working in cents)
halfs = floor(change / 50)
if halfs then print halfs + " one half dollar(s)"
change -= halfs * 50
quarters = floor(change / 25)
if quarters then print quarters + " quarter(s)"
change -= quarters * 25
dimes = floor(change / 10)
if dimes then print dimes + " dime(s)"
change -= dimes * 10
nickels = floor(change / 5)
if nickels then print nickels + " nickel(s)"
change -= nickels * 5
pennies = round(change)
if pennies then print pennies + " penny(s)"
print "Thank you, come again."
print; print
end while