1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help! Simple C Program Help!

Discussion in 'C' started by SeeUnderStudy, Oct 19, 2006.

  1. SeeUnderStudy

    SeeUnderStudy New Member

    Joined:
    Oct 19, 2006
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Yes you hardcore programmers may laugh but I can't get this working?!?!?
    I know its my functions!!

    I'm just wondering if anybody can see anything right away if they are that good at it. Obviously I am not. Thank you in advance!

    Sincerely, Frustrated and obviously new
    Code:
    /*
      Program Internet Service.
      
      Add your own documentation.
    
    */
    
    #include <stdio.h>
    #include <stdlib.h>
    
    
    
    /* Global Variables */
    int cust_num, hours, month_charge, total_cust;
    char serv_code;
    float  average, total_charge;
    
    
    
    
    /* Function Prototypes */
    void intialize_2100(void);
    void obtain_input_2200(void);
    void process_customer_2300(void);
    void display_details_2400(void);
    void calc_average_2500(void);
    void display_summary_2600(void);
    void calc_monthly_charge_3310(void);
    void update_accum_count_3320(void);
    void calc_bus_charge_4110(void);
    void calc_econ_charge_4120(void);
    void calc_unlim_charge_4130(void);
    void update_accum_4210(void);
    void update_counter_4220(void);
    
    
    
    /* Program Mainline */
    int main ()
    {
        initialize_2100();
        obtain_input_2200();
        while (cust_num !=  999)
       {
            process_customer_2300();
            display_details_2400();
            obtain_input_2200();
        }
       calculate_average_2500();
       display_summary_2600();
    
        printf ("\n\n");
        system ("PAUSE");
        return 0;
    }
    
    void intialize_2100(void)
    {
    total_cust = 0;
    total_charge = 0;
    }
    
    void obtain_input_2200(void)
    {
    printf("Enter customer number\n");
    scanf("%d", &cust_num);
    
    printf("Enter service code \n");
    scanf("%c", &serv_code);
    printf("Enter hours of use\n");
    scanf("%d", &hours);
    }
    
    void process_customer_2300(void)
    {
    calc_monthly_charge_3310();
    update_accum_count_3320();
    }
    
    void display_details_2400(void)
    {
    printf ("Results for customer number %d : \n", cust_num);
    printf ("Service Code: %c \n ",  serv_code);
    printf ("Charge for one month %f : ", month_charge);
    
    }
    
    void calc_average_2500(void)
     
    Last edited by a moderator: Oct 19, 2006
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
  3. SeeUnderStudy

    SeeUnderStudy New Member

    Joined:
    Oct 19, 2006
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Yes! Func Calls : 3220 and 4220 keep returning errors of conflicting types and declaration errors!

    I reposted the code as I noticed it was incomplete.
    Code:
    /*
      Program Internet Service.
      
      Add your own documentation.
    
    */
    
    #include <stdio.h>
    #include <stdlib.h>
    
    
    
    /* Global Variables */
    int cust_num, hours, month_charge, total_cust;
    char serv_code;
    float  average, total_charge;
    
    
    
    
    /* Function Prototypes */
    void intialize_2100(void);
    void obtain_input_2200(void);
    void process_customer_2300(void);
    void display_details_2400(void);
    void calc_average_2500(void);
    void display_summary_2600(void);
    void calc_monthly_charge_3310(void);
    void update_accum_count_3320(void);
    void calc_bus_charge_4110(void);
    void calc_econ_charge_4120(void);
    void calc_unlim_charge_4130(void);
    void update_accum_4210(void);
    void update_counter_4220(void);
    
    
    
    /* Program Mainline */
    int main ()
    {
        initialize_2100();
        obtain_input_2200();
        while (cust_num !=  999)
       {
            process_customer_2300();
            display_details_2400();
            obtain_input_2200();
        }
       calculate_average_2500();
       display_summary_2600();
    
        printf ("\n\n");
        system ("PAUSE");
        return 0;
    }
    
    void intialize_2100(void)
    {
    total_cust = 0;
    total_charge = 0;
    }
    
    void obtain_input_2200(void)
    {
    printf("Enter customer number\n");
    scanf("%d", &cust_num);
    
    printf("Enter service code \n");
    scanf("%c", &serv_code);
    printf("Enter hours of use\n");
    scanf("%d", &hours);
    }
    
    void process_customer_2300(void)
    {
    calc_monthly_charge_3310();
    update_accum_count_3320();
    }
    
    void display_details_2400(void)
    {
    printf ("Results for customer number %d : \n", cust_num);
    printf ("Service Code: %c \n ",  serv_code);
    printf ("Charge for one month %f : ", month_charge);
    
    }
    
    void calc_average_2500(void)
    {
    average = total_charge / total_cust;
    }
    
    void display_summary_2600(void)
    {
    printf("For %d customers, the average is %f:\n", total_cust, average);
    
    }
    
    void calc_monthly_charge_3310(void)
    {
     switch(serv_code)
     {
     case 'B':
          calc_bus_charge_4110();
     break;
    
     case 'E':
          calc_econ_charge_4120();
     break;
    
     case 'U':
          calc_unlim_charge_4130();
     break;
     }
     }
    void update_accum_count_3320(void)
     (
      update_accum_4210();
      update_counter_4220();
      }
    
    void update_accum_4210(void)
      {
      total_charge = total_charge + month_charge;
      }
    
    void update_counter_4220(void)
      {
      total_cust = total_cust + 1;
      }
    
    void calc_bus_charge_4110(void)
       {
        month_charge = 40 + (hours * 0.20);
        }
    
    void calc_econ_charge_4120(void)
       {
       month_charge = 20 + (hours * 0.10);
       }
    void calc_unlim_charge_4130(void)
       {
       month_charge = 30;
       }
    


    /* Code/Define all prototyped modules */




    Yes! 3220 and 4220 keep returning errors of conflicting ttpes and declaration errors!

    I reposted the code as I noticed it was incomplete.
     
    Last edited by a moderator: Oct 21, 2006
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    I have formatted your code using the bbcode. Please use the code block for the codes you post so that its easier to read.

    Some errors are
    initialize_2100 is called where as intialize_2100 is defined. See the missing i in the defined version

    Same is the case with calc_average_2500 and calculate_average_2500

    For update_accum_count_3320 function body it should start with { and not (

    Making the above consistent should compile your code.
     

Share This Page