// // program to track bank balance and transactions // prompts for initial balance, // then repeatedly for one of the following: // 't' for transaction -- amount (positive for credit, negative for debit) // and description // 'h' for transaction history // 'q' to quit // println("initial balance (integer)?") var balance = readInt var history = List[(Int, String)]() var choice = ' ' do { println("current balance $" + balance) println("what do you want to do?") println("(t for transaction, h for history, q for quit)") choice = readChar choice match { case 't' => println("enter amount (integer, positive for credit, negative for debit)") val amt = readInt println("enter description (line of text)") val text = readLine history = (amt, text) :: history balance += amt case 'h' => for (trans <- history) { println(trans) // FIXME format this better } case 'q' => println("ending balance $" + balance) case _ => println("invalid choice") } } while (choice != 'q')