Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: another programming assignment

  1. #11
    Join Date
    Dec 2010
    Posts
    256
    Rep Power
    0

    Default

    Quote Originally Posted by pweezy-f View Post
    @ crazeeplayer

    no mock exams yet. Btw wat year did u do OOP?
    long time ago..... roun 07 08 thereabout..... the programming assignments are always d same as they have to follow a set structure... or if they change they change little..... same thing for data structures dat u will do in 3rd year..... jus practise wat him give u..... an wen he give u d mock exam make sure u go through it

    Code:
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    	
    #include  <iostream>
    #include  <conio.h>
    #include <stdlib.h>
     
    class Customer {
     
       private:
          char name[20];
          char address[30];
          char city[20];
          char pcode[6];
          float acc_bal;
     
       public:
          Customer:: Customer() {              // constructor
             acc_bal = 0.00;
          }
     
          void getdata() {
             cout << "\nEnter your name: ";    cin >> name;
             cout << "\nEnter your address: ";   cin >> address;
             cout << "\nEnter your city: ";      cin >> city;
             cout << "\nEnter your postal code: ";    cin >> pcode;
             cout << "\nEnter current account balance: ";    cin >> acc_bal;
          }
     
          void deposit() {
             float dep;
             cout << "\nEnter amount to be deposited: ";
             cin >> dep;
             acc_bal += dep;
          }
     
          void withdraw() {
             float wdraw;
             cout << "\nEnter amount to be withdrawn: ";    cin >> wdraw;
             acc_bal -= wdraw;
          }
     
          void showdata() {
             cout << "Name: " << name;
             cout << "\nAddress: " << address;
             cout << "\nCity: " << city;
             cout << "\nPostal Code: " << pcode;
             cout << "\nAccount Balance: $" << acc_bal << endl;
          }
     
    };
     
    int main() {
     
       char choice;
       int flag = 0;
       int count = 0;
       int recnum;
       Customer cust[10];
     
       while (flag == 0) {
          cout << "\t\t\n\n" << "Main Menu";
          cout << "\t\n\n" << "Select by letter:";
          cout << "\t\n" << "a - Add a customer.";
          cout << "\t\n" << "d - Deposit money.";
          cout << "\t\n" << "w - Withdraw money.";
          cout << "\t\n" << "s - Show Account Information.";
          cout << "\t\n" << "q - Quit Application.\n\n";
          cout << "\t" << "Choice: ";
          choice = getche();
          switch(choice) {
             case 'a':
                system("cls");
                if (count > 10) {
                   cout << "Can't add anymore records. Press any key to return to main menu.";
                   getche();
                   break;
                }
                count += 1;
                cust[count].getdata();
                system("cls");
                break;
     
             case 'd':
                system("cls");
                cout << "\nEnter customer number: ";
                cin >> recnum;
                cust[recnum].deposit();
                system("cls");
                break;
     
             case 'w':
                system("cls");
                cout << "\nEnter customer number: ";
                cin >> recnum;
                cust[recnum].withdraw();
                system("cls");
                break;
     
             case 's':
                system("cls");
                cout << "\nEnter customer number: ";
                cin >> recnum;
                cust[recnum].showdata();
                getche();
                system("cls");
                break;
     
             case 'q':
                flag = 1;
                break;
     
             default:
                cout << "\nInvalid selection. Press a key to return to main menu.";
                getche();
          }
     
          if (flag == 1) {
             break;
          }
     
       }
       return 0;
    }
    Last edited by Arch_Angel; Oct 2, 2012 at 08:29 PM. Reason: merged multiple posts. added code tags.
    Dip,Bsc,CCNA,CCSP,MCP.. Up next MCSA WINDOWS 8, CCNA SECURITY,CCNP SWITCH,
    CCNA SEEKING AN OPPORTUNITY
    Theres no Friend Like Google..........

  2. #12
    Join Date
    Nov 2008
    Posts
    16
    Rep Power
    0

    Default

    @ jayrulez

    Which question mines or the assignment question?
    Kemar Lee

  3. #13
    Join Date
    Dec 2010
    Posts
    256
    Rep Power
    0

    Default

    execute that code an tell me if it works
    Dip,Bsc,CCNA,CCSP,MCP.. Up next MCSA WINDOWS 8, CCNA SECURITY,CCNP SWITCH,
    CCNA SEEKING AN OPPORTUNITY
    Theres no Friend Like Google..........

  4. #14
    Join Date
    Nov 2008
    Posts
    16
    Rep Power
    0

    Default

    @ crazeeplayer

    oh zeen. Been doing that from day one still an gettin good grades but ask me anything theory, i cant help you lol..........

    Your code not answering the question still. I am jus puzzled about the constructor part............

    @ crazeeplayer

    I am gettin errors.......
    Last edited by Arch_Angel; Oct 2, 2012 at 08:26 PM. Reason: merged multiple posts
    Kemar Lee

  5. #15
    Join Date
    Jun 2008
    Posts
    74
    Rep Power
    0

    Default

    Quote Originally Posted by pweezy-f View Post
    @ jayrulez

    Which question mines or the assignment question?
    The quoted question.

  6. #16
    Join Date
    Nov 2008
    Posts
    16
    Rep Power
    0

    Default

    @ crazeeplayer

    Never mind it run..........

    @ jayrulez

    What I was really asking is if the example that u gave me follows the pointers concept? or u don't know about pointers?
    Last edited by Arch_Angel; Oct 2, 2012 at 08:25 PM. Reason: merged multiple posts
    Kemar Lee

  7. #17
    Join Date
    Jun 2008
    Posts
    74
    Rep Power
    0

    Default

    Quote Originally Posted by pweezy-f View Post
    @ crazeeplayer

    Never mind it run..........

    @ jayrulez

    What I was really asking is if the example that u gave me follows the pointers concept? or u don't know about pointers?
    No, the only pointer used is the special "this" which is the internal pointer to the instance of the class.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •