Hi,

I'm new to C++ and wrote the following program for an assignment where we were supposed to put all of our code in functions and then call each one to complete a specific ATM-related task. Briefly, the program asks the user to select from 3 accounts (checking, savings, and treasury), reads the balance from a pre-written text file, shows the balance, gets the withdrawal amount, dispenses the money in hundreds with a remainder amount, shows the new balance, and writes the new balance to the text file. Each of these tasks has a corresponding function. As far as I can tell it looks good and runs properly in Visual Studio, but I was hoping that this could be confirmed. If there are any errors and you are kind enough to write me back, please just point them out, I'm not looking for answers or rewritten code.

Thanks for your time---cordelia


Code:
#include <iostream>
#include <fstream>
using namespace std;

char getAccount(char)
{
	do
	{
		system("cls");
		cout << "Greetings, Mr. Paulson." << endl << endl;

		cout << "Checking"    << endl;
		cout << "Savings"     << endl;
		cout << "US Treasury" << endl;

		cout << endl;
		cout << "From which of the above accounts would you like to make a withdrawal (c/s/t)? ";
		cin >> account;
		cout << endl;
	}while(toupper(account) != 'C' && toupper(account) != 'S' && toupper(account) != 'T');
}

long long getBalance(long long)
{	
	char getAccount(char);
	{	
		ifstream inputFile;
		switch(account)
		{
		case 'c':
		case 'C': inputFile.open("CheckingBalance.txt");
				inputFile >> balance;
				inputFile.close();
				break;
		case 's':
		case 'S': inputFile.open("SavingsBalance.txt");
			    inputFile >> balance;
				inputFile.close();
				break;
		case 't':
		case 'T': inputFile.open("TreasuryBalance.txt");
				inputFile >> balance;
				inputFile.close();
				break;
		}
	}
}

void showBalance()
{
	long long getBalance(long long balance);
	{
		switch(account)
		{
		case 'c':
		case 'C': cout << "You have $" << balance << " in your checking account." << endl;
				break;
		case 's':
		case 'S': cout << "You have $" << balance << " in your savings account." << endl;
				break;
		case 't':
		case 'T': cout << "You have $" << balance << " in your treasury account." << endl;
				break;
		}
	}
}

long long getWithdrawal(long long withdrawal)
{
	long long getBalance(long long balance);
	{
		do
		{
			cout << endl;
			cout << "How much would you like to withdraw? $";
			cin >> withdrawal;
		}while(withdrawal > balance);
	}
}

void dispense()
{
	long long getWithdrawal(long long withdrawal);
	{	
		if(withdrawal > 0)
		{
			int hundreds = 0;
			int remainder = 0;
			cout << endl;
			hundreds = withdrawal / 100;
			remainder = withdrawal % 100;
			for (int i = 1; i <= hundreds; i++)
				cout << "$100 ";
			if(remainder)
				cout << "$" << remainder;
				cout << endl;
		}
	}
	balance = balance - withdrawal;
}

void writeBalance()
{
	ofstream outputFile;
	switch(account)
	{
	case 'c':
	case 'C': outputFile.open("CheckingBalance.txt");
			  outputFile << balance;
			  outputFile.close();
			  break;
	case 's':
	case 'S': outputFile.open("SavingsBalance.txt");
			  outputFile << balance;
			  outputFile.close();
			  break;
	case 't':
	case 'T': outputFile.open("TreasuryBalance.txt");
			  outputFile << balance;
			  outputFile.close();
			  break;
	}

int main()
{
	char account = ' ';
	long long balance = 0;
	long long withdrawal = 0;

	char getAccount(char account); 

	long long readBalance(long long balance);

	void showBalance();

	long long getWithdrawal(long long withdrawal);

	void showBalance();

	void dispense();

	void writeBalance();

	cout << endl << endl;
	system("pause");
	return 0;
}