This post has been edited by Jill: 06 April 2003 - 04:11 PM
18 Replies - 1519 Views - Last Post: 04 April 2003 - 09:03 AM
#1
Classes- Help A Girl Out :p
Posted 02 April 2003 - 04:28 PM
Replies To: Classes- Help A Girl Out :p
#2
Re: Classes- Help A Girl Out :p
Posted 02 April 2003 - 04:34 PM
#3
Re: Classes- Help A Girl Out :p
Posted 02 April 2003 - 05:26 PM
#1. You've declared first name and last name as char types, and the address as an int. You may wish to use the inherent string class provided by C++, or failing that, a char array for those variables.
string FirstName; string LastName; string address;
or
char FirstName[20]; char LastName[20]; char address[50];
Quote
i need to write a program that allows the user to choose whether to:
first load up the customer information for 5 customers
then:
Depsoit
Withdraw
print customers
print transaction for customer
(i guess this would be a menu?)
Sounds good. Something like the following will do
void display_menu(void)
{
cout << "1. Deposit" << endl;
cout << "2. Withdraw" << endl;
cout << "3. Print Customers" << endl;
cout << "Print Transaction" << endl;
}
You can use the value chosen by the user in a switch statement. This is only a start mind you. Let us know if you need any more help.
This post has been edited by Amadeus: 02 April 2003 - 08:03 PM
#4
Re: Classes- Help A Girl Out :p
Posted 02 April 2003 - 09:07 PM
after entering the names and ssn number the menu box will come up to choose what you want it to do.
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
class Customer
{
private:
public:
string FirstName;
string LastName;
string address;
srring accountNum;
};
class Transaction
{
private:
public:
char Type;
int amount;
};
void display_menu(void)
{
cout << "1. Deposit" << endl;
cout << "2. Withdraw" << endl;
cout << "3. Print Customers" << endl;
cout << "Print Transaction" << endl;
}
int main
{
cout << "How many transactions would you like to process? (1-5)" << endl;
cout << "What is your First Name? " << endl;
cin >> FirstName;
cout << "What is your Last Name? " << endl;
cin >> LastName;
cout << "What is your Social Security Number? " << endl;
cin >> accountNum;
#5
Re: Classes- Help A Girl Out :p
Posted 02 April 2003 - 09:28 PM
#6
Re: Classes- Help A Girl Out :p
Posted 03 April 2003 - 01:45 AM
#7
Re: Classes- Help A Girl Out :p
Posted 03 April 2003 - 07:05 AM
Other notes:
srring accountNum;
should have the keyword string if it's a string, but you mentioned that you would be using that account number as an array index as well. For that, you should make it an int
Also, there was a small error in my display function. "Print transaction" should have a 4 next to it.
This post has been edited by Amadeus: 03 April 2003 - 07:06 AM
#8
Re: Classes- Help A Girl Out :p
Posted 03 April 2003 - 07:08 AM
#9
Re: Classes- Help A Girl Out :p
Posted 03 April 2003 - 09:31 AM
then the menu come up. like this.
void display_menu(void)
{
cout << "xxxxxxxxxxxxxxxxxxxxxxx" <<endl;
cout << "x 1. Deposit x" << endl;
cout << "x 2. Withdraw x" << endl;
cout << "x 3. Print Customers x" << endl;
cout << "x 4. Print Transaction x" << endl;
cout << "xxxxxxxxxxxxxxxxxxxxxxx" <<endl;
cin>>cchoice
This is my Problem on this code: when i type in a number it doesnt execute what i want it to do. are these case statements right? also i dont know that to do for #4
switch (cchoice)
{
case 1:
cout << "What is you SSSN? ";
cin << SSN;
cout << "How much would you like to deposit? ";
cin << sDeposit;
break;
case 2:
cout << "What is you SSSN? ";
cin << SSN;
cout << "How much would you like to withdraw? ";
cin << sAccount;
break;
case 3:
cout<<setw(20)<<"Account number"
<<setw(13)<<"Name"
<<setw(9)<<"Balance" << endl;
cout<<setw(20)<<"_________________"
<<setw(13)<<"__________"
<<setw(9)<<"_______"<<endl;
cout<<setw(20)<<sName;
cout<<setw(13)<<AccountNumber
<<setw(9)<<Balance<<endl;
break;
case 4:
break;
}
return 0;
}
This is what needs to happen when they type ina number
1. or 2. Deposit and Withdraw: it will prompt the user for the account # , and amount to enter or withdraw.
3. Print customers: will show all data( account number, names, balance) printed to screen
4. Print transaction: will prompt for a account and then print all of the transactions (type, Amount)
this is the part im stuck on, what to put into the case statements to make 1-4 happen.
This post has been edited by Jill: 03 April 2003 - 10:52 AM
#10
Re: Classes- Help A Girl Out :p
Posted 03 April 2003 - 03:10 PM
#11
Re: Classes- Help A Girl Out :p
Posted 03 April 2003 - 03:39 PM
cyberscribe, on Apr 3 2003, 05:10 PM, said:
Well, that was extremely helpful! If you'd care to read the rules of the forum, we generally try to help people as long as they're giving it a good try themselves. Jill does appear to be giving it a shot.
Is it obviously an assignment from an introductory or intermediate class? Of course it is. Could I write the entire thing, debugged and optimized, in 30 minutes or less? Of course I can. Point is, she does appear to be trying to learn.
#12
Re: Classes- Help A Girl Out :p
Posted 03 April 2003 - 05:55 PM
cyberscribe, on Apr 3 2003, 03:10 PM, said:
If you ever come in this forum with that attitude again i will be very angry!!
Jill your doin just fine! you are following the policies perfectly give me some time to look over your code and i will post some help later tonight.
#13
Re: Classes- Help A Girl Out :p
Posted 03 April 2003 - 06:54 PM
#14
Re: Classes- Help A Girl Out :p
Posted 03 April 2003 - 08:24 PM
runtime error, on Apr 3 2003, 05:55 PM, said:
You're entitled to feel however you want, but cyberscribe is somewhat right in my opinion. As long as we don't do the work for her, I think it's ok.
Not that anyone should care what I think
This post has been edited by gneato: 03 April 2003 - 08:30 PM
#15
Re: Classes- Help A Girl Out :p
Posted 03 April 2003 - 08:58 PM
|
|

New Topic/Question
Reply



MultiQuote








|