money - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

money

How do I declare money as a variable to where my program will only reconize nickels dimes quarters and dollar bills?

Thanks,

Travis


Comments

  • : How do I declare money as a variable to where my program will only reconize nickels dimes quarters and dollar bills?
    :
    : Thanks,
    :
    : Travis
    :

    Not sure exactly what you are looking for Travis -- here is some code that might help

    DEFINT A-Z

    TYPE moneytype
    penny AS INTEGER
    nickel AS INTEGER
    dime AS INTEGER
    quarter AS INTEGER
    dollar AS INTEGER
    slug AS INTEGER
    END TYPE

    DIM money AS moneytype
    DIM keyhit AS STRING
    CLS
    PRINT "input coins: "
    PRINT "p = penny"
    PRINT "n = nickel"
    PRINT "d = dime"
    PRINT "q = quarter"
    PRINT "1 = dollar"

    DO
    keyhit = INKEY$
    SELECT CASE keyhit
    CASE ""
    ' no key press - do nothing
    CASE "p", "P"
    money.penny = money.penny + 1
    GOSUB count
    CASE "n", "N"
    money.nickel = money.nickel + 1
    GOSUB count
    CASE "d", "D"
    money.dime = money.dime + 1
    GOSUB count
    CASE "q", "Q"
    money.quarter = money.quarter + 1
    GOSUB count
    CASE "1"
    money.dollar = money.dollar + 1
    GOSUB count
    CASE CHR$(27) 'escape
    END
    CASE ELSE
    money.slug = money.slug + 1
    PRINT "It is illegal to put slugs in this machine."
    GOSUB count
    END SELECT
    LOOP
    END

    count:

    t = money.penny
    t = t + 5 * money.nickel
    t = t + 10 * money.dime
    t = t + 25 * money.quarter
    t = t + 100 * money.dollar
    PRINT "total amount = $";
    PRINT t 100;
    PRINT ".";
    IF t MOD 100 < 10 THEN PRINT "0";
    PRINT t MOD 100
    IF money.slug THEN
    PRINT "and"; money.slug; "slugs"
    END IF

    RETURN

    Let me know what grade I get on my homework :)

    rg


Sign In or Register to comment.