Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Go Back   Code Forums > Application and Web Development > Standard C, C++
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 04-21-2008, 11:19 PM   #1 (permalink)
fenderist
Recruit
 
Join Date: Sep 2006
Posts: 12
fenderist is on a distinguished road
Returning string and arrays

I spent 6 hours today tryng to program this. I have not programmed C++ for about a year now and my memory is hazy. Can someone tell me what I did wrong? My codes complies but it does not ask for input as it suppose to (getline)

Code:
//Program to demonstrate the class Bank. #include <iostream> #include <string> using namespace std; class Bank { std::string AcctName; std::string AcctID; std::string CheckID[25]; public: void outAcctName( ); void outAcctID( ); void outCheckID( ); void outmakeDeposit( ); void outshowBalance( ); //string AcctName( ); //string AcctID( ); //string CheckID( ); double get_Balance( ); //double get_CheckAmt( ); int get_CheckNumber( ); private: int CheckNumber; double Balance, CheckAmt[25]; }; //string AcctName, AcctID, CheckID[25]; //double Balance, CheckAmt[25]; //int CheckNumber; Bank CheckAmt[25]; int main( ) { Bank client; char type; do { cout << "=====================" << endl; cout << "Menu............" << endl; cout << "a. Set Name" << endl; cout << "b. Set Account ID" << endl; cout << "c. Post Check" <<endl; cout << "d. Make Deposit" << endl; cout << "e. Show Balance" << endl; cout << "f. Stop" << endl; cout << "=====================" << endl; cout << "Command: "; cin >> type; switch (type) { case 'a': client.outAcctName(); break; case 'b': client.outAcctID(); break; case 'c': client.outCheckID( ); break; case 'd': client.outmakeDeposit( ); break; case 'e': client.outshowBalance( ); break; case 'f': cout << "End of Program.\n"; break; default: cout << "Not a valid choice.\n" << "Choose again.\n"; } }while (type !='c'); int exit; cin >> exit; return 0; } //Uses iostream: void Bank::outAcctName( ) { cout << "Enter Account Holder Name: "; getline(cin, AcctName); } void Bank::outAcctID( ) { cout << "Enter Account ID: "; getline(cin, AcctID); } void Bank::outCheckID( ) { cout << "Enter Check ID: "; getline(cin, CheckID[CheckNumber]); cout << "Enter Check Amount: "; cin >> CheckAmt[CheckNumber]; Balance -= CheckAmt[CheckNumber]; CheckNumber++; } void Bank::outmakeDeposit( ) { double Amt; cout << "Enter Amount of deposit: "; cin >> Amt; Balance += Amt; } void Bank::outshowBalance( ) { cout << "===================================" << endl; cout << "Name: " << AcctName << endl; cout << "Acct ID: " << AcctID << endl; cout << "Your Current Balance is " << Balance << endl; for(int K = 0 ; K < CheckNumber ; K++) cout << "\t" << CheckID[K] << "\t" << CheckAmt[K] << endl; cout << "===================================" << endl; } int Bank::get_CheckNumber( ) { return CheckNumber; } double Bank::get_Balance( ) { return Balance; }
__________________
fenderist is offline   Reply With Quote
Old 04-22-2008, 02:14 AM   #2 (permalink)
fenderist
Recruit
 
Join Date: Sep 2006
Posts: 12
fenderist is on a distinguished road
I am replying to myself

I fixed a little bit. I could not find a way to edit my previous post so.
Code:
//Program to demonstrate the class Bank. #include <iostream> #include <string> using namespace std; class Bank { std::string AcctName; std::string AcctID; std::string CheckID[25]; public: void outAcctName( ); void outAcctID( ); void outCheckID( ); void outmakeDeposit( ); void outshowBalance( ); //string AcctName( ); //string AcctID( ); //string CheckID( ); double get_Balance( ); //double get_CheckAmt( ); int get_CheckNumber( ); private: int CheckNumber; double Balance, CheckAmt[25]; }; //string AcctName, AcctID, CheckID[25]; //double Balance, CheckAmt[25]; //int CheckNumber; //Bank CheckAmt[25]; int main( ) { Bank client; char type; do { cout << "=====================" << endl; cout << "Menu............" << endl; cout << "a. Set Name" << endl; cout << "b. Set Account ID" << endl; cout << "c. Post Check" <<endl; cout << "d. Make Deposit" << endl; cout << "e. Show Balance" << endl; cout << "f. Stop" << endl; cout << "=====================" << endl; cout << "Command: "; cin >> type; switch (type) { case 'a': client.outAcctName(); break; case 'b': client.outAcctID(); break; case 'c': client.outCheckID( ); break; case 'd': client.outmakeDeposit( ); break; case 'e': client.outshowBalance( ); break; case 'f': cout << "End of Program.\n"; break; default: cout << "Not a valid choice.\n" << "Choose again.\n"; } }while (type !='f'); int exit; cin >> exit; return 0; } //Uses iostream: void Bank::outAcctName( ) { cout << "Enter Account Holder Name: "; cin >> AcctName; } void Bank::outAcctID( ) { cout << "Enter Account ID: "; cin >> AcctID; } void Bank::outCheckID( ) { cout << "Enter Check ID: "; getline(cin, CheckID[CheckNumber]); cout << "Enter Check Amount: "; cin >> CheckAmt[CheckNumber]; Balance -= CheckAmt[CheckNumber]; CheckNumber++; } void Bank::outmakeDeposit( ) { double Amt; cout << "Enter Amount of deposit: "; cin >> Amt; Balance += Amt; } void Bank::outshowBalance( ) { cout << "===================================" << endl; cout << "Name: " << AcctName << endl; cout << "Acct ID: " << AcctID << endl; cout << "Your Current Balance is " << Balance << endl; for(int K = 0 ; K < CheckNumber ; K++) cout << "\t" << CheckID[K] << "\t" << CheckAmt[K] << endl; cout << "===================================" << endl; } int Bank::get_CheckNumber( ) { return CheckNumber; } double Bank::get_Balance( ) { return Balance; }
__________________
fenderist is offline   Reply With Quote
Reply


Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help me pass my class Negative6 Java 1 05-03-2007 04:28 PM
Highlight certain words in an string markster PHP 5 01-22-2007 10:32 PM
combining arrays Engineer Standard C, C++ 11 03-12-2005 10:23 AM
Starting out with C anon C 0 02-24-2003 01:06 PM
edit? anon Lounge 10 11-21-2002 03:02 PM


All times are GMT -8. The time now is 09:11 AM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle