Hi guys,
I was just writing a wee program to calulate APR on a credit card, i was going to use a case statement, so did a bit of reading and looked at some examples, seems simple but i can't get mine to work. Could you help?
My code:
When i run the above i get this output:Code:#include <stdio.h> int main() { float balance, apr, apr_dec, interest; int term; // Ask for balance on card: printf("Enter the balance of the card.\n"); scanf("%f",&balance); printf("Card Balance = £%.2f\n", balance); // Get Rate: printf("Enter the current interest rate (APR) in percent.\n"); scanf("%f", &apr); printf("Apr = %.2f\%\n", apr); apr_dec = apr / 100; // Get Term printf("Enter the Term in Months.\n"); scanf("%d", &term); printf("Term = %d months\n"); interest = (apr_dec * balance) / 12; printf("interest = £%.2f\n", interest); int selection ; printf("Enter the type of payment : \n") ; printf("1: minimum payment\n") ; printf("2: fixed amount\n") ; printf("selection : "); scanf("%d", &selection) ; switch (selection) { case '1' : printf("Case 1"); break ; case '2' : printf("Case 2"); break ; } printf("something\n"); }
So it won't do anything in the switch. Any ideas?Code:Enter the balance of the card. 1000 Card Balance = £1000.00 Enter the current interest rate (APR) in percent. 9.9 Apr = 9.90% Enter the Term in Months. 30 Term = 30 months interest = £8.25 Enter the type of payment : 1: minimum payment 2: fixed amount selection : 1 something
Thanks in advance.
Kai.



LinkBack URL
About LinkBacks


