Thread: BOOKKEEPING PROGRAM, need help!

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    5

    Exclamation BOOKKEEPING PROGRAM, need help!

    Hey everyone, i have to write a program that does the following. I know basic C language but i obviously need more to write this program. If someone could help me out it would be most appreciated. Here are the program specs:

    You are to write a very basic bookkeeping program that allows the user to enter a series of transactions and to display both a general journal and a balance sheet.

    Your program identifies account numbers from 1000 to 1999 as asset accounts, from 2000 to 2999 as liability accounts, and from 3000 to 3999 as equity accounts.

    Your program displays a menu that offers the user four options:

    * enter a transaction
    * view the general journal
    * view the balance sheet
    * quit the program

    If the user chooses to enter a transaction, then your program prompts the user for

    * an account number (between 1000 and 3999)
    * the transaction type - whether the transaction is a debit or a credit
    * the amount of the transaction (always a positive number)

    If the user enters the account number for the very first time, your program adds the new account to the chart of accounts. Once the user has entered the transaction details, your program returns to the menu.

    If the user chooses to view the general journal, then your program displays all transactions that have been entered, in the order entered. The format of the general journal is as follows:

    General Journal
    Account Description Debit Credit
    ------- ------------------------------ ---------- ----------
    1400 3500.00
    2100 3500.00
    1000 3000.00
    1100 1000.00
    1400 2000.00
    3100 4000.00
    3200 2000.00
    1000 2100.99
    1300 2100.99


    There are 30 blank spaces for each transaction description.

    If the user chooses to display the balance sheet, then your program displays the balances for all accounts for which transactions have been entered. Your program calculates each account balance by starting at zero and accumulating for that account the amount from each transaction in the general journal. The format for the balance sheet is as follows:

    Balance Sheet
    Account Description Debit Credit
    ------- ------------------------------ ---------- ----------
    1400 1500.00
    1000 899.01
    1100 1000.00
    1300 2100.99
    ---------- ----------
    Total Assets 5500.00

    2100 3500.00
    ---------- ----------
    Total Liabilities 3500.00

    3100 4000.00
    3200 2000.00
    ---------- ----------
    Total Equity 2000.00
    ---------- ----------
    Total Liabilities and Equity 5500.00


    There are 30 blank spaces for each account description.

    Note the subtotals for the account types - assets, liabilities and equity - and the sum of the liability and equity accounts.

    You may assume a maximum of 20 transactions and a maximum of 10 different accounts. These limits will allow you to display each of the general journal and the balance sheet on a 24-line screen.

    Your program allows for gaps in the account numbering, has good error checking, and prompts the user to re-enter unacceptable data (such as non-numeric input for numeric fields or account numbers outside the range 1000-3999). Your program is also well modularized, well commented and readily open to changes in the account type ranges, the maximum number of transactions and the maximum number of accounts.

  2. #2
    Registered User divineleft's Avatar
    Join Date
    Jul 2006
    Posts
    158
    Post your source code so far

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    5
    Code:
    #include <stdio.h>
    #define ACCOUNT_MIN 1000
    #define ACCOUNT_MAX 3999
    
    main ()
    {
       int account_number, choice;
       char trans_type;
       double trans_amount;
       double debits[20], credits[20]
       while (choice != 4)
       {
          printf("1. Enter a Transaction "); 
          printf("2. View the General Journal ");
          printf("3. View the Balance Sheet ");
          printf("4. Quit the Program ");
          scanf("%d", &choice);
          if (choice == 1)
          {
             printf("Enter an account number (between 1000 and 3999) :");
             scanf("%lf", &account_number);
             while (account_number < ACCOUNT_MIN || account_number > ACCOUNT_MAX)
                {
                printf("Invalid Entry");
                printf("Enter an account number (between 1000 and 3999) :"); 
                scanf("%lf", &account_number);
                }
             printf("Enter the transaction type (d) for debit and (c) for credit: ");
             scanf("%c", &trans_type);
             while (trans_type != 'c' || trans_type != 'd')
             {
                printf("Invalid Entry");
                printf("Enter the transaction type (d) for debit and (c) for credit: ");
                scanf("%c", &trans_type);
             }
             printf("Enter the amount of the transaction (must be positive: ");
             scanf("%lf", &trans_amount);
             while (trans_amount < 0)
             {
                printf("Invalid Entry");
                printf("Enter the amount of the transaction (must be positive): ");
                scanf("%lf", &trans_amount);
             }   
    }  
          /*if (choice == 2)
          {
            
          }     
          if (choice == 3)
                
       printf("Ended Program... HAVE A GOOD DAY!!!"); */
    }

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    752
    First off, there's two basic compile errors.
    The code, as posted, is missing a '}' at the end, also:
    Code:
       double debits[20], credits[20]
    Semicolon needed

    This is also a runtime error:
    Code:
             scanf("%lf", &account_number);
    account_number is an int. Use %d to scanf it.

    Fix those errors, try running it.

    Note the error (it should not work properly for "Enter the transaction type...").

    Code:
             scanf("%c", &trans_type);
    After typing in the account number, you press Enter. This scanf statement is reading in the Enter as a character. To prevent that, use this:
    Code:
             scanf(" %c", &trans_type);

    Code:
             while (trans_type != 'c' || trans_type != 'd')
    This condition will allways evaluate to true. Probably not what you want.
    Callou collei we'll code the way
    Of prime numbers and pings!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM