Well, I tried using the debugger, but I still don't get what I'm doing wrong. Basically, this program is supposed to simulate how much making a long distance call would cost. However, I keep getting a very messed up value. I assume it has something to do with the functions. I'm not sure though. Anyone want to help me out? Thanks
Code:/*Lab B*/ #include <stdio.h> int get_gross_cost(int); int get_net_cost(int, int); int main() { //Declarations float discount_rate, regular_rate, tax, net_cost, gross_cost; int minutes, start_time; char reply; //Explanation printf("This program is designed to calculate how much a long distance call between it's"); printf("peak hours"); do { //User input printf("\n\nPlease enter what time you would like a call to start (0001-2400): "); scanf("%i", &start_time); printf("\nPlease enter the duration of the call in minutes: "); scanf("%i", &minutes); //Functions get_gross_cost(minutes); get_net_cost(minutes, start_time); printf("The gross cost of your call is %f", gross_cost); printf("\nThe net cost of your call is %f", net_cost); printf("\n\n\nWould you like to try again? <y/n>"); scanf("\n%c", &reply); } while(reply == 'y' || reply == 'Y'); return 0; } int get_gross_cost(minutes) { float gross_cost; float regular_rate=0.40; gross_cost=minutes*regular_rate; return gross_cost; } int get_net_cost(start_time, minutes) { float regular_rate; float net_cost; int tax; if (1800<start_time || start_time<800) { net_cost=(minutes*regular_rate/2); tax=(net_cost*.04); } else { float net_cost=minutes; } return net_cost; }



LinkBack URL
About LinkBacks





