Classes- Help A Girl Out :p

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 1609 Views - Last Post: 04 April 2003 - 09:03 AM Rate Topic: -----

#1 Jill  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 02-April 03

Classes- Help A Girl Out :p

Posted 02 April 2003 - 04:28 PM

This is what i need to do in C++ is make 2 classes

This post has been edited by Jill: 06 April 2003 - 04:11 PM

Is This A Good Question/Topic? 0
  • +

Replies To: Classes- Help A Girl Out :p

#2 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1876
  • View blog
  • Posts: 20,284
  • Joined: 17-March 01

Re: Classes- Help A Girl Out :p

Posted 02 April 2003 - 04:34 PM

Could you specify what you need help with Jill.
Was This Post Helpful? 0
  • +
  • -

#3 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Classes- Help A Girl Out :p

Posted 02 April 2003 - 05:26 PM

skyhawk is right, we'd be able to provide more input if we knew what problem you were having. I can, however, give you a few pointers to start with.
#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 use the account # as the position in the array
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

Was This Post Helpful? 0
  • +
  • -

#4 Jill  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 02-April 03

Re: Classes- Help A Girl Out :p

Posted 02 April 2003 - 09:07 PM

im not sure what i really need to do but this is what i have :)
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;
Was This Post Helpful? 0
  • +
  • -

#5 malkiri  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 3
  • View blog
  • Posts: 364
  • Joined: 29-March 01

Re: Classes- Help A Girl Out :p

Posted 02 April 2003 - 09:28 PM

Wot's your question? I don't get it. :)
Was This Post Helpful? 0
  • +
  • -

#6 runtime error  Icon User is offline

  • Lucky.Code
  • member icon

Reputation: 3
  • View blog
  • Posts: 629
  • Joined: 19-March 01

Re: Classes- Help A Girl Out :p

Posted 03 April 2003 - 01:45 AM

umm ok, so are you having problems with the menu coming up? Are there any error messages that you are receiving? Is a specific function not working properly? Where are you having troubles?
Was This Post Helpful? 0
  • +
  • -

#7 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Classes- Help A Girl Out :p

Posted 03 April 2003 - 07:05 AM

I think you may be wondering how to load up the information. First thing you'll have to do is declare as many instances of the class as you'll need. From there, once the user has entered information, you'll have to put it in the appropriate variables. The easiest way to do this will be to make some member functions for your classes, most notably for information entry, deletion, and manipulation.
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

Was This Post Helpful? 0
  • +
  • -

#8 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Classes- Help A Girl Out :p

Posted 03 April 2003 - 07:08 AM

I guess I should have mentioned as well that once you know how many transactions a user wishes to process, you'll have to put in a loop to carry out the specified number.
Was This Post Helpful? 0
  • +
  • -

#9 Jill  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 02-April 03

Re: Classes- Help A Girl Out :p

Posted 03 April 2003 - 09:31 AM

what i need to do is when it asks how many transactions to enter, it will keep coming up until it gets to that number.
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

Was This Post Helpful? 0
  • +
  • -

#10 cyberscribe  Icon User is offline

  • humble.genius
  • member icon

Reputation: 10
  • View blog
  • Posts: 1,062
  • Joined: 05-May 02

Re: Classes- Help A Girl Out :p

Posted 03 April 2003 - 03:10 PM

This is a classic entry-level C++ programming assignment. We used an almost identical project as an assignment halfway through the year for the "C++ for programmers" course at Berkeley. Read the book, follow the lecture notes, and fill in the blanks yourself.
Was This Post Helpful? 0
  • +
  • -

#11 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Classes- Help A Girl Out :p

Posted 03 April 2003 - 03:39 PM

cyberscribe, on Apr 3 2003, 05:10 PM, said:

This is a classic entry-level C++ programming assignment. We used an almost identical project as an assignment halfway through the year for the "C++ for programmers" course at Berkeley. Read the book, follow the lecture notes, and fill in the blanks yourself.

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.
Was This Post Helpful? 0
  • +
  • -

#12 runtime error  Icon User is offline

  • Lucky.Code
  • member icon

Reputation: 3
  • View blog
  • Posts: 629
  • Joined: 19-March 01

Re: Classes- Help A Girl Out :p

Posted 03 April 2003 - 05:55 PM

cyberscribe, on Apr 3 2003, 03:10 PM, said:

This is a classic entry-level C++ programming assignment. We used an almost identical project as an assignment halfway through the year for the "C++ for programmers" course at Berkeley. Read the book, follow the lecture notes, and fill in the blanks yourself.

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.
Was This Post Helpful? 0
  • +
  • -

#13 Jill  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 02-April 03

Re: Classes- Help A Girl Out :p

Posted 03 April 2003 - 06:54 PM

thanks for the encouragement guys, this isnt easy if your new to it. :crazy:
Was This Post Helpful? 0
  • +
  • -

#14 gneato  Icon User is offline

  • <title>Untitled Document</title>

Reputation: 0
  • View blog
  • Posts: 1,311
  • Joined: 03-September 01

Re: Classes- Help A Girl Out :p

Posted 03 April 2003 - 08:24 PM

runtime error, on Apr 3 2003, 05:55 PM, said:

If you ever come in this forum with that attitude again i will be very angry!!

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 :lol:

This post has been edited by gneato: 03 April 2003 - 08:30 PM

Was This Post Helpful? 0
  • +
  • -

#15 Nova Dragoon  Icon User is offline

  • The Innocent Shall Suffer, Big Time
  • member icon

Reputation: 36
  • View blog
  • Posts: 6,169
  • Joined: 16-August 01

Re: Classes- Help A Girl Out :p

Posted 03 April 2003 - 08:58 PM

Runtime is the moderator, your posts are his pawns, you dare defy his whims!!!
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2