* * * * * * * * * * * * * * * *Use only the drawString(String s, int x, int y) of the Graphics class to draw one "*" at a time.
Write a boolean method, isValidConfiguration(int[] columns), which takes the column configuration as the argument, and returns true only if no two queens attack each other. Hint: Assume Q1 is in position, now check for each of the queens Q2 ... QN in that order, if they are safe with the already placed queens.
Q1 |
|
|
|
|
|
|
Q2 |
|
|
|
|
|
|
Q3 |
|
Q4 |
|
|
|
|
|
|
Q5 |
|
Consider a stock brokerage firm which handles the stock transactions for its customers. Let us assume that each customer has a single account with the firm. A customer will open an account with an initial deposit. The customer will be allowed to buy and sell stocks. The customer can buy any quantity of a particular stock at the market price as long as the required funds are available. The customer can sell a stock (that they own, either fully or partially) at the market price. The customer can deposit funds into their account at any time.
The Brokerage firm charges a fee (commission) for each buy and sell transaction. Let this fee be a static variable of the Brokerage class. The firm keeps a list (use a Vector or an ArrayList) of its customers. The data about the customers is stored persistently in a text file with the following format:
CustomerName,CustomerId,Day,TrasactionType,StockSymbol,Quantity,Price
CustomerName | Name of the customer |
CustomerId | Unique ID for each customer |
Day | An Integer. A value of 1 will be used for the first day of the firm's existence |
TransactionType | Deposit/Buy/Sell |
StockSymbol | The stock ticker symbol (No value if Deposit) |
Quantity | A number, the stock quantity (No value if Deposit) |
Price | A number, the stock price for the transaction (The Deposit amount if Deposit) |
Class Brokerage
Class Account