Could someone please help me with this assignment? I am near finishing. It is just one minor problem that is preventing me from finalizing this. I added a comment /* Problem */ above the problem. I just can't seem to add up all the values for JOG_min. When I run it, I keep getting large numbers. Please help. I would really appreciate it.

/* File: cell.c
 * Team: TCC
 * Date: February 18, 2010 */

/* Two cell phone companies provide the same amount of free minutes and charge differently for excess minutes. This program calculates the cost of excess minutes per month for each cell phone company. */

#define HOLO 0.07
#define JOG 0.05

#include <stdio.h>

/* Function declarations */
int round_minutes(float minutes);


main()
{ /* Declarations */
  float min; /* Input for minutes */
  float sec; /* Input for seconds */
  float input; /* Input of minutes & seconds */

  /* Declarations for HOLO */
  float added_sec; /* Sum of input seconds */
  float added_min; /* Sum of input minutes */
  float HOLO_converted_sec; /* Converts sum of input seconds into minutes */
  float HOLO_min_total; /* Total of converted seconds and sum of minutes */
  int HOLO_min; /* rounded HOLO minutes invoked by function */
  float cost_HOLO; /* monthly cost with HOLO */

  /* Declarations for JOG */
  float excess_min; /* Total of one excess call */
  int JOG_min; /* rounded JOG minutes invoked by function */
  int JOG_min_total; /* Sum of all rounded calls */
  float cost_JOG; /* monthly cost with JOG */

        /* Obtain input for minutes & seconds */
        printf("Please enter the excess amount of time.\n");
        printf("Enter minutes, seconds: \n");
        input = scanf("%f %f", &min, &sec);


                while (input != EOF)
                {
                        /* For Holo-T */
                        added_sec = sec + added_sec;
                        added_min = min + added_min;

                        /*For JOG */
                        excess_min = (sec/60) + min;
                        printf("Excess call with JOG = %f minutes\n", excess_min);

                        JOG_min = round_minutes(excess_min);
                        printf("  Rounded excess call with jog = %d minutes\n", JOG_min);

                         /* Problem */
                        JOG_min_total = JOG_min + JOG_min_total;
                        printf("     The total of all rounded calls is %d\n", JOG_min_total);

                        /* Update loop */
                        printf("Enter minutes, seconds: \n");
                        input = scanf("%f %f", &min, &sec);

                }

/* Service provider: Jog
 * 1) Round each call
 * 2) Add each rounded call */

                /* Calculate cost with JOG
                cost_JOG = (JOG_min_total) * JOG;
                printf("At $0.05 per excess min., the total cost of all excess calls with Jog is $%f\n", cost_JOG); */

/* Service provider: Holo-T
 * 1) Add all calls
 * 2) Round the sum of all calls to the nearest minute */

                        /* Convert input seconds into minutes */
                        HOLO_converted_sec = (added_sec) / (60);
                        printf("Input seconds converted to minutes = %f minutes\n", HOLO_converted_sec);
                        printf("Total input minutes = %f minutes\n", added_min);

                        /* Sum of converted seconds and input minutes */
                        HOLO_min_total = (HOLO_converted_sec) + (added_min);
                        printf("The total of all excess calls is %f minutes\n", HOLO_min_total);

                        /* Sum of converted seconds and input minutes */
                        HOLO_min_total = (HOLO_converted_sec) + (added_min);
                        printf("The total of all excess calls is %f minutes\n", HOLO_min_total);

                        /* Invoke function to round total of excess calls */
                        HOLO_min = round_minutes(HOLO_min_total);
                        printf("The rounded total of all excess calls is %d minutes\n", HOLO_min);

                        /* Calculate cost with HOLO-T */
                        cost_HOLO = (HOLO_min) * (HOLO);
                        printf("At $0.07 per excess min., the total cost of all excess calls with Holo-T is $%f\n", cost_HOLO);

} /* End main */

int round_minutes(float minutes)

/* Given: Excess minutes in float value
 *  *  *  *
 * Returns: Excess minutes rounded to the nearest minute */

{

int value;
   value = minutes + 1.0;
        return value;

}

Up on line 33 initialize it to zero ( int JOG_min_total = 0; ). Trace it out, the first time you're going through the loop you're getting JOG_min_total = JOG_min + (whatever garbage is in this variable at the start). So if you set it to zero you'll get the JOG_min_total = JOG_min the first time through.

thank you so much jonsca!
I finally got it. I really appreciate it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.