08-17-2010, 07:48 AM
OK so i started on my C# project which requires me to make a simple ATM simulation but I've kinda gotten stuck with it and i wont be able to see my professor until Friday.
I hope to get more done by the time i do have a chat to him so I can have less/more important information to talk about instead of trying to get me unstuck from what I've done.
And my assignment specifications are
Any tips or progress is greatly appreciated. I'm not too sure how to go about with creating the accounts as well as getting the Display and Account Manus working properly.
I hope to get more done by the time i do have a chat to him so I can have less/more important information to talk about instead of trying to get me unstuck from what I've done.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication5 {
class Program {
static void Main() {
int menuOption;
TransactionMenu();
menuOption = ReadOption();
Console.ReadLine();
AccountMenu();
menuOption = ReadOption();
Console.ReadLine();
}
static void DisplayBalance(int whichAccount) {
}
static bool checkOption(int option) {
if ((option < 0) || (option > 3)) {
return true;
} else {
return false;
} //End if
} //End checkOption
static int ReadOption() {
int option = 0;
bool notValidMenuOption = false;
do {
option = int.Parse(Console.ReadLine());
notValidMenuOption = checkOption(option);
if (notValidMenuOption){
Console.WriteLine("\nOption must be 1, 2, 3 or 4");
TransactionMenu();
}
}while (notValidMenuOption);
Console.WriteLine("Option: " + option + " selected");
return option;
}
static void TransactionMenu() {
string menuOption = "\n1) Check Balancce"
+ "\n2) Withdrawal"
+ "\n3) Transfer"
+ "\n4) Exit"
+ "\n\nEnter your option(1-3 or 4 to exit):";
Console.Write(menuOption);
} //end TransactionMenu
static void AccountMenu() {
string menuOption = "\n1) Cheque"
+ "\n2) Savings"
+ "\n3) Debit"
+ "\n4) Exit"
+ "\n\nEnter your option (1-3 or 4 to exit):";
Console.Write (menuOption);
} //end AccountMenu
}
}
And my assignment specifications are
Quote:Introduction
A new Automatic Teller machine (ATM) is being designed and you have been contracted to write a C# console application program that models the proposed functionality of the new ATM.
Initial Specification
You are required to produce a program, written in C# (Visual Studio 2008), which will model the functions of an ATM (albeit in a naïve and slightly unusual manner).
The program will display a list of possible actions, read in the user’s choice, and then perform the required action. Unlike a real ATM, the user will be able to select any action from the menu and the program will be able to handle the situation gracefully.
Initial Design
A very high-level algorithm
While not finished
Display list of possible actions
Input the user’s choice
Perform the required action
End while
More Assignment Details
A number of assumptions have been made so that the assignment is able to be done using only the concepts covered in Lectures 1 – 4. You are free to use any valid programming constructs, even if they have not been covered in lectures so far.
Our model of an ATM will permit the user to choose from the following main menu:
• Obtain the available balance on any account
• Withdraw money from any account
• Transfer money from one account to another account
• Exit the simulation
(see the sample screen interactions at the end of this document)
Note, all input should be checked that it is within the acceptable range and if not the user should be informed of the acceptable range and requested to re-enter the input.
When a user chooses an action, it will affect the state of the ATM as follows:
• Obtain a balance: (DisplayBalance)
o The list of accounts is displayed
Cheque Account
Savings Account
Debit Card Account
o User will select one of these or choose to cancel this selection
o If the user has selected an account, then the current date and time is displayed along with the actual balance and available balance. The available balance is $10 less than the actual balance for the Cheque Account; the available balance is the actual balance for the Savings and the Debit Card accounts.
• Withdraw money (WithdrawAmount)
o The list of accounts is displayed
o User will select one of these or choose to cancel this selection
o If the user has selected an account
Prompt for amount to be withdrawn.
Amount to be withdrawn needs to be either
• a multiple of $20
• a multiple of $50
• some combination of $20 & $50 notes
If the withdrawal would leave less $10 in that account, no transaction occurs and the user is informed that there are insufficient funds in that account for this transaction
If the withdrawal leaves at least $10 in that account then the transaction occurs
In the case of a withdrawal from the Cheque Account, then a fee of $5 is deducted from the account as well. ( Note this may result in the balance of the account being less than $10) There is no fee for withdrawal from the Savings Account or Debit Card.
The number of notes to be collected is displayed.
Display current date, time and actual and available balance of that account
• Transfer money between accounts (TransferAmount)
o Prompt the user to choose which account to Transfer money from
o User will select one of these or choose to cancel this selection
o If the user has selected an account, they will be asked to choose which account to Transfer money to.
o If they select a Transfer to account
Prompt for amount. The amount to be transferred need not be whole number of dollars; amount like $1.23 is acceptable.
For the transaction to occur, the balance for the Transfer from account must be at least $1 more than the transfer amount. If there is insufficient funds, no transaction occurs and the user is informed of this.
For a successful transaction, there is a transfer fee of $1 that is deducted from the account from which the money was transferred, regardless of which account it is.
Display current date, time and actual and available balance of both accounts
• Exit the simulation
o A terminating message is displayed.
Assumptions
The ATM has an endless supply of $20 and $50 notes to dispense for withdrawal purposes. The amount chosen for a withdrawal must be a multiple of $20 or $50 or some combination of $20 and $50 notes.
The user will input data values of the correct type when requested to do so. That is, if an integer is expected, an integer value is entered.
All accounts must contain a minimum balance of $10 after a withdraw transaction has occurred, except where the fee charged for the transaction results in the balance being less than $10. After a transfer transaction the from account can have a minimum balance of $0.
The Cheque account balance will initially be $2000, the Savings account balance will initially be $903.55 and the Debit Card balance will be $1,000
The balance of all accounts and any symbolic constants may be instance variables, they are declared within the class but not within any method; all other variables are to be local variables of some method.
To print the current date and time use the following code (Hint: in its own method)
DateTime date = DateTime.Now;
Console.Writeline("Current Date: {0:f} ", date );
More detailed Design Specification
Some initial work had already been done on this project and the following specification of various method headings have been developed and agreed upon with the client. (If you do not use these method headings, you will lose marks)
static void DisplayBalance(int whichAccount)
Action: Current time and date is displayed along with the actual balance and the available balance of the account indicated by whichAccount. The available balance is $10 less than the actual balance for the Cheque account.
static void WithdrawAmount(int whichAccount)
Action: Provided that the withdrawal amount does not leave the account with less than the minimum balance, the amount is withdrawn from the nominated account indicated by whichAccount. If the account is the Cheque account then a fee of $5 is deducted from the remaining balance after a successful withdrawal has occurred.
static void DispenseCash(int amount)
Action: Displays a message to collect the amount consisting of the actual number of notes to be collected.
static void TransferAmount(int fromAccount, int toAccount)
Action: Provided that the transfer amount does not leave the account(fromAccount) with a balance of less than $1, the amount is transferred to the nominated account (toAccount) and a transfer fee of $1 is deducted from the account(fromAccount) after the transfer has occurred.
Assignment Goals
The assignment problem is straightforward though the actions of the ATM may seem unusual. The solution of the problem will be a C# project which will use, at least, the structured programming constructs covered in Lecture 3.
Though the code could be written as straight line code, the sheer number of lines would make the solution difficult to read, almost impossible to understand, very hard to maintain and more than likely to contain many potential logical errors. A straight line code solution will not receive full marks even if it fulfils the required functionality.
It is highly recommended that you use the methods specified above as well as few of your own design to manage the complexity as well as providing a structure to your solution. Hint: each independent action/process should be a method. The body of the Main method should resemble the given high-level algorithm above with perhaps some minor additions and some 9 or more other methods would perform the required processing.
Sub-goals of the assignment are to experience:
• Top-down design & development
• Translating simple algorithms into C# code
• Writing user defined methods
• Parameter passing
• The mechanics of editing, compiling, building and running your program
• Testing your program
• Commenting your source code
• Becoming confident and comfortable with programming in the small
• Producing a well documented solution
Electronic Submission
You will submit your assignment via the Online Assessment System (OAS) before COB (close of business) 1st September, 2010. More detailed information regarding he Online submission will be made available by 13th August, 2010.
Information regarding OAS submission can be found at.
http://www.scitech.qut.edu.au/study/curr.../index.jsp
Note OAS is a Faculty of Science and Technology System and is not part of QUT’s Assignment Minder or Blackboard Systems. It is recommended that you upload your file to the OAS from a lab at QUT. Inability to access the OAS from home is not a sufficient reason for submitting the assignment late or being given an extension.
Suggested strategy
Plan to be finished before 1st September! Do not write all of the code in one sitting and then attempt a compilation.
First week ( by 15 August): read assignment specification, clarify anything unclear with a tutor, think about how to do it, develop test plan and cases, design high-level algorithms for each independent part of the assignment. Begin to type program (with comments), in incremental stages. For example – ensure that you can correctly read in the required action first and then display the balance of a selected account before adding code to withdraw or transfer money. Seek help from a tutor if needed.
Second week (by 22 August) : Re-read specification, continue to refine design of various sections to code, enhance test plan if necessary, bring code (printout as well as on a disk) for critical review during consultation times or practicals. Finish initial coding.
Third week (by 30 August): Debug using test plan (add more to test plan if extra problems shown up by testing), another review (?), re-read specification to make sure you have done exactly what is required. Late third week: submit electronic copy to OAS before 1 September.
Final Comments
This assignment is not about screen design so do not waste time attempting to produce the fanciest looking screen output. Though you are free to alter and enrich the output statements it will not gain any additional marks. The basic interaction below is sufficient. The following pages are examples of the required basic screen interaction – note not all possible interactions have been displayed.
Any tips or progress is greatly appreciated. I'm not too sure how to go about with creating the accounts as well as getting the Display and Account Manus working properly.