![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Feb 2006
Location: Near Chicago
Posts: 5
Rep Power: 0
![]() |
I am trying to make a simple ATM C# app that will allow a user to enter a id, the program looks up the current balance, asks how much he wants to take out, chacks it with whats available, and then despences the money.
I just need a bit of help in starting out.... as I am rather new at this. Thanks |
|
|
|
|
|
#2 |
|
Programming Guru
![]() ![]() ![]() |
Window app or console? How are the balances stored, in a file or database? Have you tried any code, if so what errors are you getting?
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#3 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Your description is a fair start at defining your problem and generating pseudo-code to accomplish it. Flesh it out a tad, translate it into code, give it a shot, and post back with problems.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#4 | |
|
Newbie
Join Date: Feb 2006
Location: Near Chicago
Posts: 5
Rep Power: 0
![]() |
Quote:
As stated above, I am rather new at this (only second term in school, first term was a visual structure class, this one is C#) I understand how it should be organized, but I am not quite sure how to go about this one |
|
|
|
|
|
|
#5 |
|
Programming Guru
![]() ![]() ![]() |
Alright... I was feeling nice... This code shows you how to read the balance from a file and I included a basic TODO list... it should get you started, the rest is up to you. Post back with specific problems...
using System;
using System.IO;
namespace atm
{
class Class1
{
const string DATAFILE = "balance.txt";
[STAThread]
static void Main(string[] args)
{
double myBal = GetBalance(DATAFILE);
Console.WriteLine("My balance is: {0}",myBal);
//TODO: Prompt user for action, withdrawl or deposit... obtain amount.
// 1) Withdrawal or Deposit?
// 2) How much?
//TODO: Deposit:
// 1) Call GetBalance, assign the returned value to a variable.
// 2) Add the user defined amount to the current balance.
// 3) Set balance in DATAFILE (create a SetBalance method (write to file)).
//TODO: Withdrawal:
// 1) Call GetBalance, assign the returned value to a variable.
// 2) Check to see if sufficient funds are available.
// 3) If funds available, subtract from available balance.
// 4) Set balance in DATAFILE (create a SetBalance method (write to file)).
}
static double GetBalance(string DATAFILE)
{
StreamReader SR;
string data;
double balance = 0.0;
SR=File.OpenText(DATAFILE);
data=SR.ReadLine();
SR.Close();
balance = Convert.ToDouble(data);
return balance;
}
}
}
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." Last edited by Infinite Recursion; Feb 10th, 2006 at 2:43 PM. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|