money - Programmers Heaven

Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.