BEGIN { while (getline < "bank") { password[$1] = $2 balance[$1] = $3 } userid = getuserid() printf "Your balance is %.2f\n", balance[userid] while ((cmd = getcommand()) != "Q") { if (cmd == "D") { balance[userid] += getamount() } else if (cmd == "W") { amt = getamount() if (amt <= balance[userid]) { balance[userid] -= amt } else { print "Can't overdraw account" } } else { print "Unrecognized command" } printf "Your balance is %.2f\n", balance[userid] } print "Thank you for your custom." for (userid in password) { if (userid !~ /^ *$/) print userid, password[userid], balance[userid] > "bank" } } function getuserid( userid, passwd) { userid = ""; passwd = "hello" while (passwd != password[userid]) { printf "%s ", "Enter userid:"; getline userid printf "%s ", "Enter password:"; getline passwd } return userid } function getcommand( cmd) { cmd = "X" while (cmd !~ /[dDwWqQ]/) { printf "Enter command: D)eposit, W)ithdrawl or Q)uit: " getline cmd } return toupper(cmd) } function getamount( amt) { amt = "X" while (amt !~ /[1-9][0-9]*\.?[0-9]*/) { printf "Enter amount: "; getline amt } return amt }