roshini45 0 Newbie Poster

i know everyone hates hw help but i just need some help getting started with writing the functions. here is what i have so far:

/* ATM Simulator Function Source File			atm.c
**
** CSC-234 (M. Hutchenreuther)			John Jones
** Assignment 8 Part A				Section 1
** November 9, 2005
**
** Program: Automatic Teller Machine Simulator -- Transfer Menu
**
** Description: This file contains the function definitions.
**
** Included functions:	ShowBal()
**			Deposit()
**			Withdraw()
**			TranMenu()
**			Transfer()
**
** Revision History:	Created 8/7/01 by John Jones.
**						Added TranMenu() and ShowBal
**						to Withdraw(), Deposit(), and Transfer().
*/

#include <stdio.h>
#include "atm.h"

int main(void)
{
char szChckName [] = "Checking";
char szSaveName [] = "Savings";
char szVisaName [] = "Mustang Visa";
double dAcctBal = 600.00;


	
	
	return 0;
}

/* Function ShowBal()
**
** Description:	This function displays the current account balance.
**
** Variables:
**	Name		Type		Intent	Purpose					Units	Range
**	szAcctName	char[]		in	Name of account			n/a		n/a
**	dAcctBal	double		in	Account balance			n/a		n/a
**
** Inputs:			none
** Outputs:			szAcctName, dAcctBal
**
** Preconditions:	none
** Post-Conditions:	Account balance is displayed.
**
** Arguments:		szAcctName, dAcctBal
** Returns: 		nothing
*/

void ShowBal (char szAcctName[], double dAcctBal)
	{
	printf ("Your %s account balance is $%.2lf.\n",
	szAcctName, dAcctBal);
	}
/* end function ShowBal() */


/* Function Deposit()
**
** Description:	This function prompts the user for an amount to
**				deposit, gets that amount, and adjusts the balance.
**
** Variables:
**	Name		Type		Intent	Purpose					Units	Range
**	szAcctName	char[]		in		Name of account			n/a		n/a
**	pdAcctBal	*double		in/out	Account balance			n/a		n/a
**	dInput		double		n/a		Amount to deposit		n/a		n/a
**
** Inputs:			dInput
** Outputs:			szAcctName, dAcctBal
**
** Preconditions:	none
** Post-Conditions:	Account balance is increased by input amount.
**
** Arguments:		szAcctName, *dAcctBal
** Returns: 		nothing
*/

void Deposit (char szAcctName[], double *pdAcctBal)
	{
	if (dInput <= 0.0)
		printf ("Invalid amount.\n");
	else
		pdAcctBal = dAcctBal + dInput;
	
	ShowBal (szAcctName, *pdAcctBal);
	}
/* end function Deposit() */


/* Function Withdraw()
**
** Description:	This function prompts the user for an amount to
**				withdraw, gets that amount, and adjusts the balance.
**
** Variables:
**	Name		Type		Intent	Purpose					Units	Range
**	szAcctName	char[]		in		Name of account			n/a		n/a
**	dAcctBal	*double		in/out	Account balance			n/a		n/a
**	dInput		double		n/a		Amount to withdraw		n/a		n/a
**
** Inputs:			dInput
** Outputs:			szAcctName, *dAcctBal
**
** Preconditions:	none
** Post-Conditions:	Account balance is decreased by input amount.
**
** Arguments:		szAcctName, *dAcctBal
** Returns: 		nothing
*/

void Withdraw (char szAcctName[], double *pdAcctBal)
	{
	printf ("Not implemented yet.\n");
	/* your algorithm and code goes here */
	ShowBal (szAcctName, *pdAcctBal);
	}
/* end function Withdraw() */


/* Function TranMenu()
**
** Description:	This function prompts the user with a choice of
**              accounts to transfer to or from.
**
** Variables:
**	Name		Type		Intent	Purpose					Units	Range
**	szSourName	char[]		in		Name of source account	n/a		n/a
**	pdSourBal	*double		in/out	Source account balance  n/a		n/a
**	szDest1Name	char[]		in		Name of destin account	n/a		n/a
**	pdDest1Bal	*double		in/out	Destin account balance  n/a		n/a
**  szDest2Name char[]		in		Name of destin account	n/a		n/a
**  pdDest2Bal  *double		in/out	Destin account balance  n/a		n/a
**	cWhich		char		n/a		User choice				n/a		n/a
**
** Inputs:	cWhich
** Outputs:	None
**
** Preconditions:	none
** Post-Conditions:	none.
**
** Arguments:		szSourName, *pdSourBal, szDest1Name, *pdDest1Bal
**					szDest2Name, *pdDest2Bal
** Returns: 		nothing
*/

void TranMenu (char szSourName[], char szDest1Name[], char szDest2Name[],
               double *pdSourBal, double *pdDest1Bal, double *pdDest2Bal)
	{
	char cWhich = 'x';
	printf ("Please choose from the following:\n");
	printf ("Enter A to transfer from %s to %s,\n", szSourName, szDest1Name);
	printf ("      B to transfer from %s to %s,\n", szSourName, szDest2Name);
	printf ("      C to transfer from %s to %s,\n", szDest1Name, szSourName);
	printf ("   or D to transfer from %s to %s:\n", szDest2Name, szSourName);
	scanf ("\n%c", &cWhich);
	cWhich = toupper (cWhich);
	switch (cWhich)
		{
		case 'A':
			Transfer (szSourName, pdSourBal, szDest1Name, pdDest1Bal);
			break;
		case 'B':
			Transfer (szSourName, pdSourBal, szDest2Name, pdDest2Bal);
			break;
		case 'C':
			Transfer (szDest1Name, pdDest1Bal, szSourName, pdSourBal);
			break;
		case 'D':
			Transfer (szDest2Name, pdDest2Bal, szSourName, pdSourBal);
			break;
		default:
			printf ("Invalid choice %c.\n", cWhich);
			break;
		}
	/* end switch cWhich */
	}
/* end function Transfer() */
/* Function Transfer()
**
** Description:	This function prompts the user for a destination
**		account and an amount to transfer to or from that
*		account, gets that amount, and adjusts the balance.
**
** Variables:
**	Name		Type		Intent	Purpose					Units	Range
**	szSourName	char[]		in		Name of source account	n/a		n/a
**	pdSourBal	*double		in/out	Source account balance  n/a		n/a
**	szDestName	char[]		in		Name of destin account	n/a		n/a
**	pdDestBal	*double		in/out	Destin account balance  n/a		n/a
**	dInput		double		n/a		Amount to transfer		n/a		n/a
**
** Inputs:	dInput
** Outputs:	szSourName, pdSourBal, szDestName, pdDestBal
**
** Preconditions:	none
** Post-Conditions:	Input amount is transferred between accounts.
**
** Arguments:		szSourName, *pdSourBal, szDestName, *pdDestBal
** Returns: 		nothing
*/

void Transfer (char szSourAcct[], double *pdSourBal,
			   char szDestAcct[], double *pdDestBal)
	{
	printf ("Not implemented yet.\n");
	/* your algorithm and code goes here */
	ShowBal (szSourAcct, *pdSourBal);
	ShowBal (szDestAcct, *pdDestBal);
	}
/* end function Transfer() */

/* end file atm.c */


/* Automatic Teller Machine Simulator Header File	atm2.h
**
** CSC-234 (M. Hutchenreuther)						John Jones
** Assignment 8 Parts A and B						Section 1
** November 9, 2005
**
** Program: Automatic Teller Machine Simulator -- Transfer Menu
**
** Description: This file contains only the function prototypes. The
**				function definitions are in file atm.c.
**
** Included functions:	ShowBal()
**						Deposit()
**						Withdraw()
**						TranMenu()
**						Transfer()
**
** Revision History:	Created 8/7/01 by John Jones.
*/

extern void ShowBal (char[], double);
	/* acct name and balance */
extern void Deposit (char[], double*);
	/* acct name and balance */
extern void Withdraw (char[], double*);
	/* acct name and balance */
extern void TranMenu (char[], char[], char[], double*, double*, double*);
extern void Transfer (char[], double*, char[], double*);
	/* source acct name and balance, destination acct name and balance */

/* end file atm.h */

i have to complete the Deposit, Withdraw, and Transfer functions, but am not quite sure where to go. i started the deposit function but didn't get very far. if anyone has any hints or pointers i would really appreciate it! thank you!

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.