Programming help!!!!

Discussion in 'School Work Help' started by worgorgec, May 16, 2009.

  1. worgorgec

    worgorgec Well-Known Member

    60
    234
    0
    Im doing programming in uni as a first year student we're learning C# and i ahve no idea what is going on and in this weeks lab we have to construct an example of an ATM machine which really doesn't help because i really dont know whats going on.

    Create appropriate class called ‘Account’. This class has the following attributes: account number, a balance, a pin and the name of the owner.
    The class has these methods:
    ·[FONT=&quot] [/FONT]A constructor which initialises the account attributes.
    ·[FONT=&quot] [/FONT]Deposit method to take a deposit (it increments the balance by the deposit made).
    ·[FONT=&quot] [/FONT]Withdraw method (it decrements the balance by the withdrawal made).
    ·[FONT=&quot] [/FONT]Display method to display all details of an account.
    ·[FONT=&quot] [/FONT]SetBalance which sets the balance to a given amount.

    Exercise 2: (3 marks)
    Create two objects account as follows:
    [FONT=&quot] static Account ac1 = new Account(1234, 0101, 1000.0);[/FONT]
    [FONT=&quot] static Account ac2 = new Account(1111, 2222, 0.50);[/FONT]

    Your task is to provide a stripped down Automatic Teller Machine (ATM) interface to the two objects created. The interface initially presents two options on the first menu asks:

    Welcome!

    Choose one of the two options:
    1. Enter account and corresponding pin number
    2. exit
    Enter option 1, 2:

    Once a user chooses option 1, he needs to first enter the account number followed by a valid pin number before proceeding any further, valid pins are 1111 or 2222. The interface display would be

    Please enter your account number:

    If the account number is valid, the above is followed by

    Enter Pin Number Please:

    The user has as many attempts as they require.

    When the user enters a valid pin, the user is presented with the following menu:

    Main Menu: Choose one of the 4 options:
    1. View my balance
    2. Withdraw cash
    3. Deposit funds
    4. Exit
    Enter a choice:

    Implement each of the above operations. Options 2 and 3 prompt the user for the amount to withdraw or deposit respectively. The balance is adjusted accordingly. At the end of any transaction or balance display the menu is presented again unless the user chooses exit.

    Finish the functionalities for the first menu before proceeding to the second menu. In developing each menu, program in stages, for example:
    (a) Prompt the user with a choice of the options. Collect their response and print a description of the choice they made so that you know the first step is working.
    (c) Add a loop to your main method so that users can choose an option multiple times (until they select exit).



    This is my lab and i don't know where to start i'm hoping sum1 can give me an idea as to where to begin
     
  2. bestknightmare

    bestknightmare Active Member

    35
    31
    0
    looks like a pretty fun assignment! I only took one comp sci course for fun so cant really help u much.

    looks like it is already pretty simplified, create a class and define those variables

    but it looks like there are mistakes in your instructions

    ac1 has account number 1234, pin 0101, cash 1000.0
    ac2 has account number 1111, pin 2222, cash 0.50

    but contradicts afterwards that only accept pins that are 1111 or 2222
    so essentially, you can never accept PIN from "ac1"
     
  3. worgorgec

    worgorgec Well-Known Member

    60
    234
    0
    LOL yeah thanks our lecturer always makes mistakes in his lab instructions that could be a reason why im not learning anything in his course what so ever -blush
     
  4. dragong87

    dragong87 Well-Known Member

    853
    68
    0
    i did one similar when i did computing.. use a do-while loop for the menu part.. (i found that way the easiest)

    thats all i remember. lol
     
  5. Sponge_bob

    Sponge_bob Well-Known Member

    70
    31
    0
    I am a mechanical engineer and I have programming study during my graduation course . Assuming you are doing C programming now . This is a very very easy assignment , I can finish it in 10 minutes , but you have to try on your own . Will give you a few head up . You can start by defining all the variables that you need .

    First , draw your flow chart of your system . Defining by blocks and charts and looping needed . You can add if loop at any wrong input of every printf .You can use coding like this :

    int main()
    {
    int n;
    cout<<"Enter n value \n";
    cin>>n;
    switch (n) {
    case 1:
    cout << "the number is 1 "<<endl;
    break;
    case 2:
    cout << "the number is 2 "<<endl;
    break;
    default:
    cout<<"the number is not 1 or 2"<<endl;
    break;
    }
    return 0;
    }

    This is only a sample and not your answer , but the solution is close to this , think logically , apply loop , make sure all the semicolon and bracket are correct . Again I ensure , this is easier than you thought . Your lecturer is kind enough to provide you chain of command in the coding . Otherwise , you have figure out yourself . Goodluck !
     
  6. fong06

    fong06 Member

    16
    26
    0
    [FONT=&quot] static Account ac1 = new Account(1234, "0101", 1000.0);[/FONT]
    [FONT=&quot] static Account ac2 = new Account(1111, "2222", 0.50);
    don't forget the quotes at ur pin. It should be a string.
    Did you finish ur assignment already? I have almost the same assignment before. If u need it, I can post it here. I didn't have the perfect solution for this btw.

    Maybe someone know a better way to do this.
    My problem is solved with a IF loop for EACH account ( so it will work now, cause there is only 2 account made, but how can it be done without a extra each if for each account? Is there something like sets of java in C? [/FONT]
     
  7. zylo

    zylo Well-Known Member

    210
    243
    12
    i had to do this to pass. only did it in c++ though i can probably do i in c#. is it c# with a gui or without
     
  8. worgorgec

    worgorgec Well-Known Member

    60
    234
    0
    THANKS FOR ALL UR HELP GUYS!!! :D ive already got my lab marked i only got 3.5/5 but at least i passed ^^
     
  9. fong06

    fong06 Member

    16
    26
    0
    and how did u fixed for checking each account? kinda curious =)
     
  10. chinabean

    chinabean Member

    10
    26
    0
    omg...this brings back so much memories from my first year at DeVry University lol...to bad I don't remember crap on C# or C++ anymore...since I guess idk...haven't had a programming class in a while, gotta re-learn it whenever my track classes start I guess lol
     
  11. rdyupah

    rdyupah Well-Known Member

    46
    234
    0
    This sounds very simple, though I mainly did programming in C++ in my university days. But I've reviewed C# a bit. You can use an array class, such as List. But if in a larger scale for scalability and speed, can use a tree node to find an account faster. But of course, in a real world environment, of course it will be used in a database environment. For in your case, using a List class is more than enough. Sorry I'm 4 weeks late looking through this post, else I could probably have help you do it to pass my time and make sure you get a 4+ out of 5