Basic ATM Problem, NEED HELP PLEASE

So I have this laboratory problem in my programming class and I can't seem to get what to do here. There are already some codes given but I don't know how to supply the cases. Please read what is written below then let me know if you can suggest codes that will help me out. Basically this is just a program that works like an ATM machine. Thank you :)




Write the definitions of the declared function prototypes of the given code. This program should be able to simulate ATM functionalities. No modification should be done in the given codes (main function and function prototypes).

# include <iostream.h>
#include<stdlib.h>

voidselectMenu ();
//this function will display the main menu options
//and will return a value of the selected transaction
// the program should validate the input : selection of options should be 1,2,3 and 4 only
//use do -while loop for validation of option

doubledepositMoney(double mon);
//this function will simulate deposit transaction
//this function will update the balance once a successful
//deposit transaction occured.
//this function should not allow deposit if amount to deposit is from 100.00 to 400.00
//for the program not to terminate in this case, perform a do while loop to validate the deposit amount and as the user to re enter amount of 500 and/or above .

void widrawMoney(double& WMoney);
//this function will simulate withdraw transaction
//balance should be updated once a success withdraw transaction occurred.
//this function should not allow withdrawal if amount to withdraw is less than 500.00
//maximum withdrawal amount is 5000.00
//withdrawal amount should be displayed with the following breakdown: 100,200,500, and 1000
//for example amount is Php1800.00 breakdowns are:
// 1000  1 =1000.00
// 500  1 = 500.00
// 200  1= 200.00
// 100  1= 100.00
// Total : Php 1800.00

double balanceInquiry (double);
//this function should display the remaining balance

void quitProgram( );
//this function will terminate the program using the exit pre-defined object

char tryAgain();
//this function will ask the user if he wants to do another transaction
//this function should return a char type basedon selection made by the user
// Y for yes and N for no will be the ONLY accepted value(s)
//use toupper function for the input
//re-enter the value if the user inputs other character than Y and/or N : use another do-while loop for the validation.


void main()
{
double balance=10000.00;
char ch;
int select,password;

cout<<”Please enter 4 digit password:”;

cout<<showpoint<<fixed<<setprecision(2);
do
{
select = selectMenu ();

switch (select)
{
case 1://add code here for DepositMoney
break;
case 2: ://add code here for widrawMoney
break;
case 3:://add code here for balanceInquiry;
break;
case 4:://add code here forquitProgram();

}
//you can add code here

ch = tryAgain ();
}while (ch=='Y' || ch == 'y');
}

Note: you are only required to write the function definition. Thus, you are not allowed to make any modifications in the main function and on the function prototypes unless there is “//add code here for……”. Any modifications will result a deduction from your lab exercise.
Please be guided accordingly.
No, let's see some code you have written and compiled. You don't expect anyone here to write code from scratch do you?

Also, the code presented is prone to errors, do the following changes:
voidselectMenu (); change to void selectMenu ();

...

void main() change to int main() and add return 0; at the end of main().

And please use code tags, (<> in the format box on the right).
Last edited on
closed account (o3hC5Di1)
Hi there,

Although Mr. ToniAz has a point in us not going to do the work for you, I think some more clarification of your assignment may help get you on your way.

The main thing in the task description is this:

fidelers23 wrote:
Write the definitions of the declared function prototypes of the given code.


You have been given declarations of functions, such as void selectMenu ();, this is like telling the compiler "just so you know, the function selectMenu will be defined somewhere in this file, ready for you to use it when you need to." Not doing this would involve the risk of the compiler throwing errors at you for "undefined functions".

Now, an example of a function declaration and definition would be as follows:

1
2
3
4
5
6
7
8
//telling the compiler there is a function called print_text, which takes a string as an argument
void print_text(std::string text);  

//actually defining the function viz. telling the compiler what this function should actually do when called
void print_text(std::string text)
{
    std::cout << text;
}


Off course that's a bit of a silly example, but you get the point hopefully.

So, as to your particular situation, a vague example, which you'll have to work out further yourself for it to work.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//  --- Declaration
void selectMenu ();

// --- Definition
//this function will display the main menu options
//and will return a value of the selected transaction
// the program should validate the input : selection of options should be 1,2,3 and 4 only
//use do -while loop for validation of option

void int selectMenu()
{
    int answer;
    do
    {
        /* print menu options to screen and ask for an answer */
    } while (/* answer is smaller than zero or bigger than 5 (1-4) */)

   return answer; 
}


Now, whoever wrote that code for you was in a hurry, this function is supposed to return something, according to the description, so it can never be of type void. Void functions don't return anything, they just do something without giving feedback.

Anyway, I hope that gets you on your way at least.

All the best,
NwN
Last edited on
You got me wrong here, I'm asking help to help me come up with a code for the 4 cases here. I have no idea how to start it.
closed account (o3hC5Di1)
Hi there,

Well I'm willing to walk you through each one, but not by just giving you the code.

Referring to the code of my last post:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//  --- Declaration
void selectMenu ();

// --- Definition
//this function will display the main menu options
//and will return a value of the selected transaction
// the program should validate the input : selection of options should be 1,2,3 and 4 only
//use do -while loop for validation of option

int selectMenu()
{
    int answer;
    do
    {
        /* print menu options to screen and ask for an answer */
    } while (/* answer is smaller than zero or bigger than 5 (1-4) */)

   return answer; 
}


Tht's pretty much half the work done:


//this function will display the main menu options
//and will return a value of the selected transaction
// the program should validate the input : selection of options should be 1,2,3 and 4 only
//use do -while loop for validation of option


So, alter that function to "display the main menu options" and ask the user for input.
It has to go within the do/while loop so that the menu will be prompted as long as the user does not input a valid option.

For more on the working of loops and do/while: http://cplusplus.com/doc/tutorial/control/#loops

All the best,
NwN
/*
* Programmer: Bretaña, Fidel Jhon A.
* Date Created: 7/17/2012
* Terminal No: 13
* Program: MSIT
* Course / Section: CS127L/BC1
* Purpose: This program will should be able to simulate ATM functionalities.
*/
# include <iostream.h>
#include<stdlib.h>

void selectMenu ();
//this function will display the main menu options
//and will return a value of the selected transaction
// the program should validate the input : selection of options should be 1,2,3 and 4 only
//use do -while loop for validation of option

double depositMoney(double mon);
//this function will simulate deposit transaction
//this function will update the balance once a successful
//deposit transaction occured.
//this function should not allow deposit if amount to deposit is from 100.00 to 400.00
//for the program not to terminate in this case, perform a do while loop to validate the deposit amount and as the user to re enter amount of 500 and/or above .

void widrawMoney(double & WMoney);
//this function will simulate withdraw transaction
//balance should be updated once a success withdraw transaction occurred.
//this function should not allow withdrawal if amount to withdraw is less than 500.00
//maximum withdrawal amount is 5000.00
//withdrawal amount should be displayed with the following breakdown: 100,200,500, and 1000
//for example amount is Php1800.00 breakdowns are:
// 1000 ' 1 =1000.00
// 500 ' 1 = 500.00
// 200 ' 1= 200.00
// 100 ' 1= 100.00
// Total : Php 1800.00

double balanceInquiry (double);
//this function should display the remaining balance

void quitProgram();
//this function will terminate the program using the exit pre-defined object

char tryAgain();
//this function will ask the user if he wants to do another transaction
//this function should return a char type basedon selection made by the user
// Y for yes and N for no will be the ONLY accepted value(s)
//use toupper function for the input
//re-enter the value if the user inputs other character than Y and/or N : use another do-while loop for the validation.

void main()
{
double balance=10000.00;
char ch;
int select;

do
{
void selectMenu ();
do{
cout<<"[1] Withdraw"<<endl
<<"[2] Deposit"<<endl
<<"[3] Balance"<<endl
<<"[4] End Transaction"<<endl;
cin>>select;
switch (select)
{
case 1:


break;
case 2: //add code here for widrawMoney
break;
case 3://add code here for balanceInquiry;
break;
case 4:// user has selected quit
break;
}//you can add code here
ch=tryAgain();

}while (ch=='Y' || ch == 'y');
system("cls");
}

So far there was just one error, it's unexpected file error thingy, and it comes up near the end of the code and I don't know how to fix it.
Last edited on
Topic archived. No new replies allowed.