need help in this work ....

goal
This work is to develop a system capable of managing bank accounts.
description
The banking system consists of a set of two banks where each bank has a manager, responsible for the accounts of that bank. Also part of the banking customers (maximum 100), which can have up to 03 accounts. Each account has a number and balance.
Code to create the number of accounts:
current
10NNN
savings
20NNN
investment
30NNN
Account numbers are generated automatically by the system.
example:
The system should allow, through a menu of options, performing the following operations: including banks, including bank accounts, refers to all accounts of a person (report on behalf of the bank manager's name and balance), the query all accounts of a bank (report with customer name, balance); deposit in an account of a person (to inform the account number, bank and value), drawing on an account of a person (to inform the account number the bank and the value);

guys, I've tried and not succeeded, I lost a few classes in college and takes a lot of this work, I'm sure you guys for this is easy and quick to do. If you guys do not help me stay without doing the work. I appreciate your attention.

Struct, and case program

Recommended Answers

All 12 Replies

First off, we don't do other people's homework for them. Second, we don't do other people's homework for them. And third, we don't do other people's homework for them. Sensing a pattern here yet?

No one here will simply hand you a solution on a silver platter. If you show us what you've done, what you've tried to do, and what problems you've had with it, then we'll be happy to help. If you have specific questions, we can answer them, or at least point you in the right direction. If you have a program with a bug you can't swat on your own, we'll be glad to assist, so long as you pay attention to the forum rules and post sensible questions in an intelligent manner that we have some reasonable hope of answering.

But just cutting and pasting an assignment into a message, without even prefacing it with something like, "I have this homework problem that I can't solve...", is likely to get you booted from the message boards here and elsewhere - if you're lucky. What happens to you if you are unlucky is... well... let's just say that this guy probably won't be trying that again, on that forum or this one.

And in case you think you won't get caught... think again.

We take this issue seriously here. Very seriously. Asking us to do homework for you is a grave breach of academic ethics on your part, and actually doing so would be an even bigger breach on ours (not that this stops the many fine mercenaries at vWorker and Scriptlance, but still). Simply posting this here, in this way, could get you expelled from your school, if someone happens to notice it and blow the whistle on you. Furthermore, it does neither you nor us any good to help you cheat - especially since there's a good chance some day one of us will have to work with you, manage you, or, Eris forefend, fix code you've written. We have an obligation to our profession and our own future sanity to help you become a good programmer, and doing your coursework for you isn't going to do that.

The problem description is somewhat daunting, I have to admit, but even for a beginning student, it shouldn't be to difficult. Post what you've already tried and we'll look at it, but please don't just dump your problems in our laps like this.

commented: Agreed. +14

The moust simple way is that you can have max like 300 accounts(300 structs) and 100 users(structs)
2 banks structs then you link them somehow together this does not need to be effective way, cause data is very small. See for example to be easy you can store 3 account struct in the user and users can be stored in some bank struct it all depends on the specification, how will you add data or delete, and search, as i see here i dont even understand what user is, it actually can be hard and effective which is meaningless here or easy. Or you can use 2 banks files where every line have user ,account count, then accounts and numbers and read them as getline.

It is all about imagination, try this it will be fun

schol-r-l everything you wrote is absolutely right, the problem this week to discover that my father has one year of life due to cancer. Because of this missed classes and missed the matter, I would not be here begging if that work was not important, if not I'll fail to deliver. I appreciate the attention of all and wish that my acc was not blocked, I liked the forum and want to learn here. thank you

complementing, if anyone has experienced a tightening "cast the first stone," I know that my father's illness and not an excuse, but if you still have someone willing to help me my email is [snipped] Peace and plenty of programming to all ......

I think eveyone here would be willing to help, if you could show that you've made some effort with it yourself. I realize that your circumstances are hard, and I am willing to accept that you need help; but we still need to know that you are sincere in your intentions.

What all this means, practically speaking is: show us the code. It doesn't matter how incomplete or broken it is, so long as it shows that you have made a genuine effort to solve the problem. That, plus a thoughtful explanation of what it is supposed to be doing and what is going wrong, is all we really ask of you.

Please, whatever you do, don't just give up and walk away from here. We will help you, but you have to show your work first. Be patient and considerate to us, and we will show you the same courtesy.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct bank {
       char name[100];

}
main ()
{

     int i, aux;
     char name[100]    
     for (;;) 
     {
         system ("cls");
         printf ("1- Include bank\n");
         printf ("2- Include account\n");
         printf ("3- query to all accounts of a person\n");
         printf ("4- query to all accounts of a bank\n");
         printf ("5- deposit in an account of a person\n");
         printf ("6- Serve in an account of a person\n");
         printf ("7- Exit\n");
         fflush (stdin);
         scanf ("%d", &aux);

         switch (aux)
         {
                case 7: 
                     exit(0);

                case 1: 

                     system ("pause");
                     }
                     }
                     }

this is what I have practically nothing ... know when your head does not think because of my father ... so to ask for help .... still do not know how to thank you guys ....

has no data base, the code seems to be simple. struct and case

OK, I'll start by making three points. First, it is a good idea to always give an explicit return type for all functions, especially main(), which must by of type int if you are to write portable code. Second, while it is a common mistake, you should never apply fflush() to any input stream, including stdin. Finally, you generally want to avoid using the system() function for screen management, as explained here and here.

Having said that, I will turn to the actual issues with your code.

The Bank structure should really be the key one here, and I think you need to give it some more work. At the very least, you'll want to have both the name or identifier for the bank branch itself, and the name of the bank manager.

struct Bank
{
    unsigned int branch_number;
    char manager[128];
};

You then want a struct type for the bank accounts, which will hold an account number, and an account balance.

struct Account
{
    char account_number[5];
    int balance;
 };

You'll also want another struct type for the bank customers, which would have the customer's name, a customer ID number, and an array of three Accounts. You'll then want an array of 100 bank customers to hold all the possible accounts.

struct Customer
{
    char name[128];
    unsigned int id;
    struct Account accounts[3];
} customers[100];

As for the operations you're supposed to have, the wording of the problem is a bit confusing in places. Just what does 'including banks' mean? Do they want a listing of the banks? The same question applies to 'including bank accounts'. There seems to be some translation issues here.

The easiest part should be displaying the information about the accounts, followed by making deposits and withdrawals. I would work on those parts next.

#include <stdio.h>
#include <stdlib.h>
#include <struct.h> 

struct Bank
{
    unsigned int branch_number;
    char manager[128]; //why 128?
};
struct Account
{
    char account_number[5]; //why 5 account? if need 3 ?
    int balance;
}
struct Customer
    char name[128];  //would not be 100 client?   
    unsignet int id;
    struct account accounts[3]
}customers[100]

main ()
            int i, aux;
            char bank1, bank2;
            for(;;)
            {
                 system ("cls");  
                 printf ("1- Include bank\n");
                 printf ("2- Include account\n");
                 printf ("3- query to all accounts of a person\n");
                 printf ("4- query to all accounts of a bank\n");
                 printf ("5- deposit in an account of a person\n");
                 printf ("6- Serve in an account of a person\n");
                 printf ("7- Exit\n");
                 scanf ("%d", &aux);

                 switch (aux)
                 {
                        case 7:
                             exit(0);
                        case 1: //I believe it is
                             printf ("Enter the 1st database and manager: \n");
                             scanf ("%d", &bank1);
                             printf ("Enter the 2nd database and manager: \n");
                             scanf ("%d", &bank2);    

                             }
                             return (0)
                             }

        schol do not know how to thank you for your help

Why 128 characters for the name? Call it a habit of mine; if I am using an arbitrary size for something, I usually use a power of 2 rather than a power of ten. The reasoning behind this is a bit obscure, being related to the Zero-One-Infinity Rule, but basically the idea is that powers of two 'fit' better for many programming purposes than powers of ten, and if nothing else look less obviously arbitrary.

As for why five characters for the account numbers, if you look at the problem statment again, that's how many are required. The first two characters hold the type of the account, as given in the problem statement.

From what you said, I gather that 'include' here is meant in the sense of 'add'. That explains a good deal, as I was wondering how account creation was supposed to go.

In the main() function, you have bank1 and bank2 declared as type char. This would mean that they are each one character long; that isn't really enough to accomplish what you are trying to do with them. Rather than that, I would recommend using the structure types I've already suggested.

    struct Bank banks[2];

By using an array, you then have a logical relationship between the two values, as well.

Now, when reading in the values, you want to read the bank ID seperately from the manager's name; since one is an unsigned int and the other is a char array, trying to read them both together won't work. I'd recommend writing a small function for this purpose, as you have to be able to do it for both of the banks in question separately.

void readBank(struct Bank banks[])
{
    char buffer[BUFFER_SIZE];
    unsigned int branch;
    static unsigned short count = 0; /* track how many branches have already been read in */

    /* sanity check - do we already have two banks set up? */
    if (count >= 2)
    {
        printf("You already have two banks set up.");
        return;
    }

    printf("Enter a branch ID number for the %s branch: ", (count == 0 ? "first" : "second"));
    fgets(buffer, BUFFER_SIZE, stdin); 
    sscanf(buffer, "%u", &branch);
    banks[count].branch_number = branch;

    printf("Enter the branch manager's name: ");
    fgets(buffer, BUFFER_SIZE, stdin);
    strncpy(buffer, banks[count].manager, BUFFER_SIZE);

    count++;  /* increment count so that we know how many banks already exist */
}

You should add #include BUFFER_SIZE 128 at the top of the program if you use this code as-is.

schol I thank your help, more "void" "array" not learned yet, you spend a vo exercise we did in class for you have an idea what to ask ... very simple and has no "database" only to insert client etc ....

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct student {
       char name[41];
       float note1, note2, media;

}
main ()
{
     struct student classe[20];
     int i, aux, y, aux1;
     char name1[41];

     for (;;) 
     {
         system ("cls");
         printf ("1- Add student\n");
         printf ("2- note shows a 1 student\n");
         printf ("3- note show classes\n");
         printf ("4- exit\n");
         printf ("5- Find name\n");
         printf ("6- show the names of students who are under consideration\n");
         fflush (stdin);
         scanf ("%d", &aux);

         switch (aux)
         {
                case 4: 
                     exit(0);

                case 1: 
                     printf ("Enter the data\n");
                     for (i=0;i<3; i++)
                     {
                         printf ("student %d \n", i+1);
                         printf ("name \n");
                         fflush (stdin);
                         gets (classe[i].name);
                         printf ("note1 ");
                         fflush(stdin);
                         scanf("%f", &classe[i].note1);
                         printf("note2 ");
                         fflush(stdin);
                         scanf ("%f", &classe[i].note2);
                         classe[i].media=(classe[i].note1+classe[i].note2)/2;
                         }
                           break;   
                            case 2:
                              printf("enter the number of students \n");
                              fflush (stdin);
                              scanf ("%d", &aux);
                              printf("name =%s \n", classe[aux-1].name);
                              printf("note1=%.2f,\nnote2=%.2f \n", classe[aux-1].note1, classe[aux-1].note2);
                              printf("media=%.2f \n", classe[aux-1].media);      
                                      break;
                                      case 3:
                             for (y=0;y<3; y++)
                             {
                              fflush (stdin);
                              printf("name =%s \n", clasee[y].name);
                              printf("note1=%.2f,\nnote2=%.2f \n", classe[y].note1, classe[y].note2);
                              printf("media=%.2f \n", classe[y].media);
                              break;
                              case 5:
                                  aux1=0;
                                  fflush (stdin);
                                  while (aux1!=1)
                                  {
                                   puts ("enter the name of the student");
                                   gets (name1);
                                   for (i=0;i<3;i++)
                                   {
                                       if (strcmp(name,classe[i].name)==0)
                                       {
                                         printf ("note1=%.2f\n", calsse[i].note1);
                                         printf ("nota2=%.2f\n", classe[i].note2);
                                         aux1=1;
                                         }
                                         }
                                         if (aux1==0)
                                         puts ("not have this student in class");
                                         }

                                          break; 
                                                 case 6:
                                                      puts ("students in exam");
                                                      for (i=0; i<3;i++)
                                                      {
                                                          if (classe[i].media>=4&&classe[i].media<7)
                                                          puts (classe[i].name);
                                                          }
                                                          break;
                     }
                     system ("pause");
                     }
                     }
                     }
//schol I thank your help, more "void" "array" not learned yet, you spend a vo exercise we did in class for you have an idea what to ask ... very simple and has no "database" only to insert client etc.

Ah, I see. If arrays and functions present a problem for you, this may be a bit difficult.

I will say that it's clear you have worked with arrays already, even if you don't know them as such. An array is a variable that holds a group of values of the same type, rather than just the one value normally found in a variable. An array in C is declared like these below:

char my_array[10];
struct student classe[20];
struct Bank banks[2];

you then access a given value inside of an array like so:

my_array[0] = 'H';
classe[5].name = "John Doe";

You may know these by some other name in Portuguese, or by the alternate Enlgish names 'vector' or 'table'. You'll also note that a string in C is nothing more than a char array that ends in a null character ('\0').

Functions may be another story; if you haven't learned about them yet, it may be that I'd be jumping ahead of your coursework if I explained them to you now. Still, a bit of preview may not hurt, so here goes. A function is a separate part of a program, which can be called from some other part of the program to perform a task or compute a value. Functions usually take some kind of values in as arguments, and usually return a result.

You have already been using functions which are part of the standard library, such as printf() and system(). These are usually taught as if they were part of the language, but strictly speaking, they are part of the language library, not the core language itself. For that matter, the main() function which you write as the body of the program is a special case of a function, one which is set up to be the starting point of the program when the operating system loads it to be executed. A typical function might look like this:

int gcd(int m, int n) 
{
    if ((m % n) == 0)
      return n;
   else
      return gcd(n, m % n);
 }

This function takes two int arguments (or parameters), and returns an int result. This particular function is a little unusual, in that it calls itself in the process of computing it's value; this is what is called a recursive function. The ability to perform tasks recusively is just one of the reasons for breaking programs into separate functions.

If a function has the void type, then it doesn't return a result; you call void functions just for their side-effects. In the case of the readBank() function I gave you earlier, it's side effects are to ask the user for the branch number and manager's name, and to put those values into the banks[] array which was passed to it as a reference argument.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.