Programming Exercise

ATM Machine

In this assignment you will create a program that allows a user to do the following:

1) Create a bank account by supplying a user id and password.
2) Login using their id and password.
3) Quit the program.

Now if login was successful the user will be able to do the following:

1) Withdraw money.
2) Deposit money.
3) Request balance.
4) Quit the program.

If login was not successful (for example the id or password did not match) then the user will be taken back to the introduction menu.

This is what your program in action will look like:

Hi! Welcome to my ATM Machine!

Please select an option from the menu below:

l -> Login
c -> Create New Account
q -> Quit

l

Please enter your user id: 12
Please enter your password 2345

******** LOGIN FAILED! ********

Please select an option from the menu below:

l -> Login
c -> Create New Account
q -> Quit

c

Please enter your user name: 12
Please enter your password: 2345

Thank You! Your account has been created!

l -> Login
c -> Create New Account
q -> Quit

l

Please enter your user id: 12
Please enter your password: 2345

Access Granted!

d -> Deposit Money
w -> Withdraw Money
r -> Request Balance

d

Amount of deposit: $20

d -> Deposit Money
w -> Withdraw Money
r -> Request Balance

r

Your balance is $20.

d -> Deposit Money
w -> Withdraw Money
r -> Request Balance

w

Amount of withdrawal: $2.5

d -> Deposit Money
w -> Withdraw Money
r -> Request Balance

r

Your balance is $17.5.

d -> Deposit Money
w -> Withdraw Money
r -> Request Balance

q

Thanks for stopping by!

#include <stdio.h>
#include <stdlib.h>
#include
void printIntroMenu();
void printMainMenu();
void start();
void login();
void createAccount();

// global variable (use this variable to store the user’s menu selection)
char menuInput;

// the main function
int main()
{
    // TO WRITE A WELCOME MESSAGE HERE

        // call the function start
        start();

        return 0;
}

void printIntroMenu()
{
    // WRITE CODE HERE
}

void printMainMenu()
{
    // WRITE CODE HERE
}

void start()
{
    // EXPLANATION OF CODE THAT GOES HERE IS BELOW
}

void createAccount()
{


}

void login()
{

}

The function printIntroMenu() displays the following:

Please select an option from the menu below:

l -> Login
c -> Create New Account
q -> Quit

The function printMainMenu() displays the following menu:

d -> Deposit Money
w -> Withdraw Money
r -> Request Balance
q -> Quit

>

The function start() does the following:

1) Displays the following message, “Please select an option from the menu below: ”

2) Displays the introduction menu. Do this by calling the function you created earlier, printIntroMenu()

3) Program halts and waits for the user to make their selection.

4) Now use a switch statement to do the following:
If the user types the character ‘l’ then the function login() is called
If the user types the character ‘c’ then the function createAccount() is called.
If the user types ‘q’ your program will terminate by calling the function exit(0)

printf("Please fill in the boilerplate code provided and one of our human code bots may decide to assist you\n");

what is boilerplate???? all you need to do is to fill out the missing code

and no, you don't need help ASAP. Your problem is no more urgent than the stuff I've on my plate that'd cost the customer a lot of money if it's not resolved quickly.
And doing your homework for you (you've clearly not put in any effort whatsoever, just copied your assignment here verbatim) isn't what we're here for.

commented: ASAP+ +5

all you need to do is to fill out the missing code

No, you need to make an honest attempt to fill out the missing code.
No code from you = no help from us.

ok sorry here is the code that I tried I really don't know how to finsh it

#include <stdio.h>
#include <stdlib.h>

    // function prototypes
void printIntroMenu();
void printMainMenu();
void start();
void login();
void createAccount();

// global variable (use this variable to store the user’s menu selection)
char menuInput;

// the main function
int main()
{
    printf("GOOD DAY! Welcome to Invesment ATM\n");

        // call the function start
        start();

        return 0;
}

void printIntroMenu()
{
    printf("    Please select an option from the menu below:\nl     -> Login\nc -> Create New Account\nq -> Quit\n> ");


}

void printMainMenu()
{
    // WRITE CODE HERE
}

void start()
{
    printf("Please select an option below\n");
    printIntroMenu();
    scanf("%c",&menuInput);
    switch(menuInput){
    case'l':login();break;
    case'c':createAccount();break;
    case'q':exit(0);break;



    }

}

void createAccount()
{
    int usern,password;
    printf("Enter your desired username:\n");
    scanf("%d",&usern);
    printf("Enter you desired password:\n");
    scanf("%d",&password);
}

void login()
{
    int username, p;
    printf("Enter your username");
    scanf("%d",&username);
    printf("Enter your password");
    scanf("%d",&p);
    if(username&&p==username&&p);
    printf("Acess Granted");
    else if
    printf("******** LOGIN FAILED! ********");

}

will you please help with the other parts??

no, you don't need help ASAP. Your problem is no more urgent than the stuff I've on my plate that'd cost the customer a lot of money if it's not resolved quickly.
And doing your homework for you (you've clearly not put in any effort whatsoever, just copied your assignment here verbatim) isn't what we're here for.

I'm so sorry for my action I just want to learn programming

I'm really sorry, I copied my assignment there so that my post is comprehensive...I didn't know that I should put on the code that I have made....I'm really sorry, it will not happen again... I hope you would accept my apology

nullptr and jwenting

Also what I meant by ASAP was I badly need help...anyways thank you so muchBold Text Here

Move lines 41 to 45 to printIntroMenu()
I gather that the user id and password are both mean't to be positive integers, if that's the case then it seems that the same userid and password variables would be needed by createAccount() and login()
You can pass these variables as pointers if you learned about pointers otherwise define them as global variables (edit: given the function signatures, just use global variables). Initialize them both to a negative integer e.g -1
If login() is selected, test whether userid and password are -1, if they are then the user needs to first create an account. Display a message to indicate this.

In login, have two local variables e.g int temp_id, temp_pass;
take the input into these local variables, then test.

if (temp_id == userid && temp_pass == password)
// if successful login call printMainMenu()

I'm off to bed so I'll leave with the above. Hopefully it points you in the right direction. :)

can you please lend a hand in my syntax for log-in

#include <stdio.h>
#include <stdlib.h>

    // function prototypes
void printIntroMenu();
void printMainMenu();
void start();
void login();
void createAccount();

// global variable (use this variable to store the user’s menu selection)
char menuInput;

// the main function
int main()
{
    printf("GOOD DAY! Welcome to Invesment ATM\n");

        // call the function start
        start();

        return 0;
}

void printIntroMenu()
{
    printf("    Please select an option from the menu below:\nl     -> Login\nc -> Create New Account\nq -> Quit\n> ");


}

void printMainMenu()
{
    // WRITE CODE HERE
}

void start()
{
    printf("Please select an option below\n");
    printIntroMenu();
    scanf("%c",&menuInput);
    switch(menuInput){
    case'l':login();break;
    case'c':createAccount();break;
    case'q':exit(0);break;



    }

}

void createAccount()
{
    int userid=0, password;

    printf("Enter your desired username:\n");
    scanf("%d",&userid);
    printf("Enter you desired password:\n");
    scanf("%d",&password);
}

void login()
{

    int tempid, tempp,userid=0,password;
    printf("Enter your username");
    scanf("%d",&tempid);
    printf("Enter your password");
    scanf("%d",&tempp);
    if(tempid==userid&&tempp==password)
    printf("Hi");


}

Hellow guys, I need a full code of that TM machine Question.
Thank You

Please send me the code

commented: Sure. It's 1.2.3.4.5. See https://www.youtube.com/watch?v=a6iW-8xPw3k +15
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.