Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Help! Simple C Program Help! (http://www.go4expert.com/forums/help-simple-c-program-help-t1674/)

SeeUnderStudy 19Oct2006 11:03

Help! Simple C Program Help!
 
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)


shabbir 19Oct2006 15:51

Re: Help! Simple C Program Help!
 
You have posted it as an Article under the Article / Source code section. I have moved it to the Queries and Discussion forum.

Can you point as to what is working and where you are stuck. Its not possible to compile the complete code tell you what you need to be doing ....

SeeUnderStudy 19Oct2006 17:35

Re: Help! Simple C Program Help!
 
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.

shabbir 21Oct2006 09:15

Re: Help! Simple C Program Help!
 
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.


All times are GMT +5.5. The time now is 16:39.