I'm trying to write a program to calculate a bill for a user after they enter in some details.
It doesn't allow the user to enter in a value for the 'use code', instead skipping that step. Below is only a rough draft of the program, there's plenty still to be done but i'm having real difficult in getting getchat to work the way I want it. Any help would be greatly appreciated
#include <stdio.h>
int main()
{
char code;
int account,consump;
double bill;
printf("Enter account no.: ");
scanf("%d", &account);
printf("Enter consumption in kwh: ");
scanf("%d", &consump);
printf("Enter your use code: ");
code=getchar();
if(code=='R' || code=='r')
{
bill = 6.052;
printf("Bill %f\n", bill);
}
else if(code=='C' || code=='c')
{
bill = 60;
printf("Bill %f\n", bill);
}
else if(code=='I' || code=='i')
{
bill = 70.00078;
printf("Bill %f\n", bill);
}
printf("Account no: %d\n", account);
return 0;
}