Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 My bank machine
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
princess




PostPosted: Wed Jun 18, 2003 9:26 pm   Post subject: My bank machine

ok another one of my ugly programs this one took me forever........ i don't even understand why.... its soo freaking simple...

code:

var balance : real %globel variable
var font1, font2 : int
balance := 1000 %assigning variable a value
font1 := Font.New ("Lucida Console:48:Bold")
font2 := Font.New ("Lucida Console:14")



procedure Deposit %start of procedure
    colourback (gray)
    cls
    drawfillbox (50, 50, 750, 550, black)
    var deposit : real %declaring all variables
    Font.Draw ("DEPOSITS", 300, 400, font1, brightgreen)
    %Title of the procedure
    colourback (black)
    colour (white)
    locate (25, 37)
    put "Enter amount of deposit: $" .. %Asking for user input
    get deposit %user input
    balance := balance + deposit %adding deposit to the balance
    put "Current balance: $", balance : 0 : 2 %outputing the new balance
    delay (3000)
end Deposit %end of procedure



procedure Withdrawal %start of the procedure
    colourback (gray)
    cls
    drawfillbox (50, 50, 750, 550, black)
    var withdrawal : real %decalre all variables
    Font.Draw ("WITHDRAWALS", 300, 400, font1, brightgreen)
    %Title of the procedure
    colourback (black)
    colour (white)
    locate (25, 37)
    put "Enter amount of withdrawal: $" .. %asking for user input
    get withdrawal %user input
    if withdrawal <= balance then
        %start of the outer if statement-only condition
        if withdrawal rem 10 = 0 then
            %start of the innter if statement-first condition
            balance := balance - withdrawal
            %takes amount of money out of the withdrawal
        else %for the error message
            locate (26, 37)
            put "Invaild amount(most be a multiple of 10)"
        end if
    else %if the balance is less than withdrawal
        locate (26, 37)
        put "Insufficient Funds"
    end if %end of the if statements
    put "Current balance: $", balance : 0 : 2
    %displays balance after withdrawal
    delay (3000)
end Withdrawal %end of procedure



procedure FastCash
    var opt : int
    loop
        colourback (gray)
        cls
        drawfillbox (50, 50, 750, 550, black)
        Font.Draw ("FAST CASH", 300, 400, font1, brightgreen)
        %Title of the procedure
        colourback (black)
        colour (white)
        locate (25, 37)
        put "Choose an option"
        locate (27, 37)
        put "1.) $10"
        locate (28, 37)
        put "2.) $20"
        locate (29, 37)
        put "3.) $40"
        locate (30, 37)
        put "4.) $80"
        locate (31, 37)
        put "5.) $100"
        locate (32, 37)
        put "6.) Cancel"
        locate (34, 37)
        put "Your choice: " ..
        get opt
        if opt = 1 then
            if balance < 10 then
                locate (33, 33)
                put "Insufficient Funds"
                delay (2000)
            else
                balance := balance - 10
                exit when opt = 1
            end if
        elsif opt = 2 then
            if balance < 20 then
                locate (33, 33)
                put "Insufficient Funds"
                delay (2000)
            else
                balance := balance - 20
                exit when opt = 2
            end if
        elsif opt = 3 then
            if balance < 40 then
                locate (33, 33)
                put "Insufficient Funds"
                delay (2000)
            else
                balance := balance - 40
                exit when opt = 3
            end if
        elsif opt = 4 then
            if balance < 80 then
                locate (33, 33)
                put "Insufficient Funds"
                delay (2000)
            else
                balance := balance - 80
                exit when opt = 4
            end if
        elsif opt = 5 then
            if balance < 100 then
                locate (33, 33)
                put "Insufficient Funds"
                delay (2000)
            else
                balance := balance - 100
                exit when opt = 5
            end if
        elsif opt > 6 then
            locate (33, 34)
            put "Invaild Option"
            delay (2000)
            cls
        else
            locate (33, 34)
            put "Cancelled"
            exit when opt = 6
        end if
    end loop
    put "Current Balance: ", balance : 0 : 2
    delay (3000)
end FastCash



procedure Balance
    put "Your Current Balance: $", balance
    delay (3000)
end Balance

procedure Main
    loop
        colourback (gray)
        cls
        drawfillbox (50, 50, 750, 550, black)
        var s : int
        Font.Draw ("MAIN MENU", 300, 400, font1, brightgreen)
        Font.Draw ("How may I help you?", 350, 350, font2, white)

        Font.Draw ("1. Deposit", 375, 325, font2, white)
        Font.Draw ("2. Withdrawal", 375, 300, font2, white)
        Font.Draw ("3. Fast Cash", 375, 275, font2, white)
        Font.Draw ("4. Balance", 375, 250, font2, white)
        Font.Draw ("5. Exit", 375, 225, font2, white)
        colourback (black)
        locate (35, 48)
        colour (white)
        put "Option #: " ..
        get s
        delay (2000)
        cls
        if s = 1 then
            Deposit
        elsif s = 2 then
            Withdrawal
        elsif s = 3 then
            FastCash
        elsif s = 4 then
            Balance
        elsif s = 5 then
            put ""
            put ""
            put "Thank You & Good-Bye"
            exit when s = 5
        else
            put ""
            put "Invaild Option"
        end if
    end loop
end Main



setscreen ("graphics:800;600")
Main
Sponsor
Sponsor
Sponsor
sponsor
Droobie




PostPosted: Tue Jan 18, 2005 11:12 am   Post subject: (No subject)

hmm update this..try to make it more interactive like putting in a pin number and such add come simple graphics Shocked
Drakain Zeil




PostPosted: Tue Jan 18, 2005 4:05 pm   Post subject: (No subject)

I didn't look into really, but it seems to me that the center of your program can be changed to a few lines with a for end for loop, where all those IFs are.
AsianSensation




PostPosted: Tue Jan 18, 2005 8:44 pm   Post subject: (No subject)

notice the original post date...2003!!!
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: