ok,recently ,i working on a assignment,but i cant think the solution to work on it,hope u guys can help
Code:
double const balance=20;
double curr_balance;
printf("\nWhat you want to do? To Call(1),SMS(2),TopUp(3),EXIT(4) :");
scanf("%d",&choice);
{
if (choice==1)
{
printf("\nHow long had u called?(minute) : ");
scanf(" %d",&minute);
cha_rate1=minute*CHARGE1;
cha_rate2=(minute-10)*CHARGE2;
cha_rate3=(minute-20)*CHARGE3;
if (minute < 11)
{ printf("\n==================TIME========RATE=====CHARGES\n");
printf("1st Band : %3.1d.0 minutes @ RM 0.50 = RM %6.2f\n",minute,cha_rate1);
printf("2nt Band : 0.0 minutes @ RM 0.40 = RM 0.00\n");
printf("3rd Band : 0.0 minutes @ RM 0.20 = RM 0.00\n");
printf("\t ==========\n");
printf("\t Charge for this call is RM %6.2f\n",cha_rate1);
printf("\t ==========");
curr_balance -= balance+-cha_rate1;
printf("\nYour Remaining Balance is %.2f ",curr_balance);
}
else if (choice==2)
{ int sms;
printf("\nYou have choosen to SMS\n");
printf("How many SMS u want to send?");
scanf("%d",&sms);
printf("The charge rate for SMS is RM 0.10\n");
printf("Total charge for %d SMS is RM %.2f\n\n",sms,sms*0.10);
curr_balance-=balance-(sms*0.10);
printf("Your Remaining Balance is %.2f",curr_balance);
}
}
how should combine choice 1 balance and choice 2 balance together?( i will be using loop to reapeat whole process), and sometimes need start with choice 2 first.