-2
#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);


      }

need help with incorrect display of files outputed for client records
need help creating function that will update different inputs in each file eg. updating name

Edited by justin_17

Votes + Comments
Posing the same crap twice just makes you twice as lazy.
2
Contributors
1
Reply
10
Views
1 Year
Discussion Span
Last Post by rubberman
0

No description of problem - no help. Also, either declare the functions before you use them, or put them above main() and each other as an alternative. You want us to analyze 240 lines of code with no description of what your actual problem is, other than you obviously have a display/output problem, and that you want us to do your work with regard to an update function for different inputs? Sorry. Won't happen...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.