#include <stdio.h>
#include <stdlib.h>
int Client_Records();
int outstanding_balances();
int  total_company_expenses();
int profit_loss();
void file_guard();
void file_sentinel();
struct records
{
    char client_first_name[30];
    char client_last_name[30];
    char street_adress[20];
    int phone_number;
    char email_adress[20];
    char client_security_package[20];
    int annual_package_fee;
    int payment_made;
    int annual_vehicle_servicing_expences;
    int employee_pay;
    int lot_rental_fees;
    int utility_bill_payments;
    int total_expenses;
    int total_company_earnings;
    int loss;
    int gain;
    };  


void menu();
int main()



{
    file_guard();

menu(); 


}

void menu()
{

int choice=0;
    {
        printf("------alistair technologies company Records------\n");
        printf("welcome to the alistair technologies company rcords database. \n");
        printf("please choose an opption to begin browsing.\n");
        printf("[1]New Client Record\n");
        printf("[2]Overdue Payments\n");
        printf("[3]Total Company Expenses\n");
        printf("[4]Profit or loss\n");
        printf("Enter Choice\n");
        scanf("%d",&choice);
        switch(choice)
        {
        case 1:
        Client_Records();
         break;
            case 2:
        outstanding_balances();
    break;

    case 3:
        total_company_expenses();
        break;

    case 4: 
        profit_loss();
      break;
    }
    }   

}

int Client_Records()
        {
            getchar();
            FILE *fptr;
     struct records alstr;
    fptr = fopen("Client Records.txt", "a+");
            getchar();
            system("cls");
                {
    printf("client first name:");
    scanf("%s",alstr.client_first_name);

    printf("client last name:");
    scanf("%s",alstr.client_last_name);

    printf("client phone number:");
    scanf("%d",&alstr.phone_number);
    fflush(stdin);
    printf("street adress:");
    scanf("%s",alstr.street_adress);
    fflush(stdin);
    printf("client email adress:");
    scanf("%s",alstr.email_adress);
    fflush(stdin);
    printf("security package:");
    scanf("%s",alstr.client_security_package);
    fflush(stdin);
    printf("annual package fee:");
    scanf("%d",&alstr.annual_package_fee);
    fprintf(fptr,"%s %s %d %s %s %s %d ",alstr.client_first_name,alstr.client_last_name,alstr.phone_number,alstr.street_adress,alstr.email_adress,alstr.client_security_package,alstr.annual_package_fee); 
fclose(fptr);
            }
     return 0;

}
    int outstanding_balances()
    {
            getchar();
           FILE *fptr;
        struct records alstr;
        fptr = fopen("Outstanding Balances.txt", "a+");
        getchar();
            system("cls");
        {
    printf("client first name:");
    scanf("%s",&alstr.client_first_name);

    printf("client last name:");
    scanf("%s",&alstr.client_last_name);

    printf("security package:");
    scanf("%s",&alstr.client_security_package);

    printf("annual package fee:");
    scanf("%d",&alstr.annual_package_fee);

    printf("enter payments made:");
    scanf("%d",&alstr.payment_made);

    fprintf(fptr,"%s %s %s %d %d ",alstr.client_first_name,alstr.client_last_name,alstr.client_security_package,alstr.annual_package_fee,alstr.payment_made);

       if(alstr.payment_made<alstr.annual_package_fee){
        fprintf(fptr,"OUTSTANDING BALANCES\n\n");

    }
     else if(alstr.payment_made=alstr.annual_package_fee){
     fprintf(fptr,"No fees outstanding\n\n");
        } 
   }                 

fclose(fptr);
return 0;   }

   int total_company_expenses()
     {
      getchar(); 
       FILE *fptr;
    struct records alstr;
    fptr = fopen("Total Company Expenses.txt", "a+");
    getchar();

            system("cls");
            printf("vehicle servicing expenses:");
            scanf("%d",&alstr.annual_vehicle_servicing_expences);
            printf("total employees salaries:");
            scanf("%d",&alstr.employee_pay);
            printf("annual lot rental fees:");
            scanf("%d",&alstr.lot_rental_fees);
            printf("utility bills payments:");
            scanf("%d",&alstr.utility_bill_payments);
            alstr.total_expenses=alstr.annual_vehicle_servicing_expences+alstr.employee_pay+alstr.lot_rental_fees+alstr.utility_bill_payments;
            printf("Total Expenses: %d \n",alstr.total_expenses); 
            fprintf(fptr," %d %d %d %d ",alstr.annual_vehicle_servicing_expences,alstr.employee_pay,alstr.lot_rental_fees,alstr.utility_bill_payments);
            fprintf(fptr,"%d",alstr.total_expenses);

    fclose(fptr);   
    return 0;
   }
int profit_loss()
    {
            getchar();
            FILE *fptr;
             struct records alstr;
            fptr = fopen("profit and loss.txt", "a+");
            getchar();
            system("cls");
            printf(" total expenses:");
            scanf("%d",&alstr.total_expenses);
            printf("total company earnings:");
            scanf("%d",&alstr.total_company_earnings);

            fprintf(fptr,"%d %d ",alstr.total_expenses,alstr.total_company_earnings);

            alstr.gain=alstr.total_company_earnings-alstr.total_expenses;

            alstr.loss=alstr.total_expenses-alstr.total_company_earnings;

            if (alstr.total_expenses>alstr.total_company_earnings)
            {

                 fprintf(fptr,"%d", alstr.loss);
                printf("the company has icurred a loss\n");
                fprintf(fptr,"the company has icurred a loss\n");

            }
            else if(alstr.total_expenses<alstr.total_company_earnings)
            {

                fprintf(fptr,"%d",alstr.gain);
                printf("the company has earned a profit\n");
                fprintf(fptr,"the company has earned a profit\n");
    }
fclose(fptr);
return 0;
}



     void file_guard()
      {
        FILE *fptr;
     if( (fptr=fopen("Client Records.txt","Outstanding Balances.txt" "r" "r"))==NULL)
     {
        fptr=fopen("Client Records.txt","Outstanding Balances.txt" "w" "w") ;

     }
      fclose(fptr);


      }

      void file_sentinel()
      {
        FILE *fptr;
     if( (fptr=fopen("Total Company Expenses.txt","profit and loss.txt" "r" "r"))==NULL)
     {
        fptr=fopen("Total Company Expenses.txt","profit and loss.txt" "w" "w") ;

     }
      fclose(fptr);


      }

Edited 7 Months Ago by Reverend Jim: Adding !!!!!!!! will not increase your chances of getting help

Comments
Lazy.

Sorry Justin, but this is a repost of the same cruft that I commented on before... I am downposting this as a result.

You can't be bothered to describe the problem you are having or even take the time to provide a clear thread title. All you have done is post a whack of uncommented code. And you expect someone here to take the time to decipher it, determine what you are trying to do, then fix it for you?

Edited 7 Months Ago by Reverend Jim

This article has been dead for over six months. Start a new discussion instead.