Project #85708 - C++

Lab 7: Functions Objective This lab is to make you familiar with functions, pass-by-reference and multiple files. Assignment: Write a program to emulate an ATM. Present the user with 4 choices – Deposit, Withdraw, Check balance and Exit. Declare and define two functions deposit(int cash, int & balance) and withdraw(int cash, int & balance) that take 2 arguments and return nothing. Declare the variable ‘balance’ in the main file and initialize it to 5000. When the user selects an option, perform the appropriate action. Repeat the menu until the user selects the option to exit. Create 2 functions: void deposit(int cash, int & balance); void withdraw(int cash, int & balance); Create 3 separate files. In the main file, create the menu and get the user’s choice. In the header file, declare the function prototypes and include any files you might use. Create another file to define the functions declared in the header file. Syntax: Declare the functions before main() as follows: return_type function_name(parameters); Invoke the function in main(). If the function returns a value assign it to a variable. var_name = function_name(parameters); Define the function after closing main() return_type function_name(parameters) { . . . } Expected Output: Welcome to The Best Bank in the World 1. Deposit 2. Withdraw 3. Check your Balance 4. Exit Enter your choice: 1 Enter the amount you want to deposit : 200 $200 deposited successfully. Welcome to The Best Bank in the World 1. Deposit 2. Withdraw 3. Check your Balance 4. Exit Enter your choice: 2 Enter the amount you want to withdraw: 300 $300 has been dispensed. Please collect your cash. Welcome to The Best Bank in the World 1. Deposit 2. Withdraw 3. Check your Balance 4. Exit Enter your choice: 3 Your balance is $4900 Welcome to The Best Bank in the World 1. Deposit 2. Withdraw 3. Check your Balance 4. Exit Enter your choice: 4 Goodbye! Your program will be graded on: ï‚· Use of meaningful variable and constant names. ï‚· Proper use of spacing for indentations. ï‚· The program header (in which you specify the program description, your name, section, etc). ï‚· Adequate commenting, i.e. function descriptions, pre conditions, post conditions. ï‚· Use of proper messages to prompt for input and labels to describe the output. ï‚· Correctness of the program Steps: 1. Make a new directory named Lab7 under cs1580 folder and go into that directory 2. Open a new C++ file and write the code (jpico filename.cpp) 3. Write, Compile and Run the program (fg++ *.cpp –o lab7) (./lab7)

Subject Computer
Due By (Pacific Time) 10/07/2015 05:02 pm
Report DMCA
TutorRating
pallavi

Chat Now!

out of 1971 reviews
More..
amosmm

Chat Now!

out of 766 reviews
More..
PhyzKyd

Chat Now!

out of 1164 reviews
More..
rajdeep77

Chat Now!

out of 721 reviews
More..
sctys

Chat Now!

out of 1600 reviews
More..
sharadgreen

Chat Now!

out of 770 reviews
More..
topnotcher

Chat Now!

out of 766 reviews
More..
XXXIAO

Chat Now!

out of 680 reviews
More..
All Rights Reserved. Copyright by AceMyHW.com - Copyright Policy