GIDForums  

Go Back   GIDForums > Computer Programming Forums > CPP / C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 11-Jun-2007, 06:35
tlwilson04 tlwilson04 is offline
New Member
 
Join Date: Jun 2007
Posts: 1
tlwilson04 is on a distinguished road

Banking Lab


Please take a look at this code and help me to finish:

CPP / C++ / C Code:
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>


using namespace std;

int main()
{
	ofstream outData;

	char accountType;
	double minimum=0;
	double current=0;
	double charge =0;
	double s=0;
	double c= 0;
	//bool done = false;
	
	outData.open("g:\\testingData.out");

	cin>> accountType;
	cin>> minimum;
	cin>>current;

	if (accountType < minimum)
		charge = 10;
	else
		if (accountType = minimum)
			s = .04 || c = .05;


	outData.close();


return 0;

}

Thanks

Thomas
Last edited by LuciWiz : 11-Jun-2007 at 07:13. Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
  #2  
Old 11-Jun-2007, 09:48
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,619
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Banking Lab


Quote:
Originally Posted by tlwilson04
Please take a look at this code and help me to finish:
Finish what? What is it that you expect the code to do? What is it that you require the code to do? What would you like for us to do? What?


Regards,

Dave
  #3  
Old 20-Jun-2007, 02:00
it career it career is offline
New Member
 
Join Date: Jun 2007
Location: askexpert.info
Posts: 4
it career is on a distinguished road

Re: Banking Lab


I guess you want to read the input from file.
  #4  
Old 21-Jun-2007, 04:45
davis
 
Posts: n/a

Re: Banking Lab


Quote:
Originally Posted by tlwilson04
Please take a look at this code and help me to finish:

CPP / C++ / C Code:
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>


using namespace std;

int main()
{
	ofstream outData;

	char accountType;
	double minimum=0;
	double current=0;
	double charge =0;
	double s=0;
	double c= 0;
	//bool done = false;
	
	outData.open("g:\\testingData.out");

	cin>> accountType;
	cin>> minimum;
	cin>>current;

	if (accountType < minimum)
		charge = 10;
	else
		if (accountType = minimum)
			s = .04 || c = .05;


	outData.close();


return 0;

}

Thanks

Thomas

You are declaring accountType as a char and asking your program to see if it is less than a double called minimum.

The idea of comparing an account "type" to what appears to be a minimum account "balance" sounds fairly wrong to me. Let's assume that we had a few different TYPES of (bank) accounts, such as:

Checking
Savings
Money Market
CD
...etc:

...and that we assigned some type values that map to these names. Let's say:

CPP / C++ / C Code:
char AccountTypes[] = { 'c', 's', 'm', 'd' };

That way, when we were reading in a file, we could have a minimum account balance for each type such that:

CPP / C++ / C Code:
float MinimumBalances[] = { 1000.00F, 100.00F, 100000.00F, 5000.00F };

...might make sense for each corresponding account type. That is, the index of each element in the two arrays coincide with their respective intention. AccountTypes[0] is a kind of "checking" account where the minimum balance required would be contained in MinimumBalances[0] whose value is assigned to be $1000.00 else:

CPP / C++ / C Code:
float UnderMinimumBalanceServiceFees[] = { 10.00F, 2.50F, 100.00F, 25.00F };

...one would be charged UnderMinimumBalanceServiceFees[0] ($10.00) if their balance for that TYPE of account went below the MinimumBalances[0] amount.

Here is what it might look like in "code:"

CPP / C++ / C Code:
enum ACCOUNT_TYPES { CHECKING            = 0,
                     SAVINGS             = 1,
                     MONEY_MARKET        = 2,
                     CERTIFICATE_DEPOSIT = 3 };

// read the actual values from a file                     
float MinimumBalances[] = { 1000.00F, 100.00F, 100000.00F, 5000.00F };
float UnderMinimumBalanceServiceFees[] = { 10.00F, 2.50F, 100.00F, 25.00F };

int main()
{
    // this is not pseudo-code, it is bogus-code

    Open Accounts File
    Open Minimum Balances/Service Fees File
    
    Read Minimum Balances into Array
    Read Service Fees into Array
    Close Minimum Balances/Service Fees File
    
    Loop Through Accounts File
    Compare Account Balance & Account Type against Minimum Balance[Account Type]
    if( Account Balance < Minimum Balance )
    {
        // Assess Service Fee
        Modify Account Balance by Service Fee Amount
        Write to Accounts File
    }
    
    Close Accounts File
    
    return 0;
}

:davis:
 

Recent GIDBlogFirst week of IA training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 06:19.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.