Hey guys, I need some help with looping. I am writing a currency converter (who in begining programming isn't these days) and I want to have it loop so that I can it keep asking for another entry or make it quit. Here is what I have so far:
include <stdio.h>
#include <stdlib.h>
/* Main Program */
int main(void)
{
float USD;
float CAD;
float EUR;
float GBP;
float CHF;
float YEN;
int input;
char q;
/*Title of program*/
printf("\t This program will convert foreign currency to US Dollars\n\n");
/*Assigning Values*/
USD = 1.0; /* US Dollar*/
CAD = 1.2257; /* Canadian Dollar*/
EUR = 0.752162; /* European Euro */
GBP = .51573; /* British Pound */
CHF = 1.134; /* Swiss Franc*/
YEN = 1.038; /* Japanese Yen*/
printf("Please choose form the following list of currency or press q to quit.\n");
printf("\n");
printf("[1] Canadian Dollar\n");
printf("[2] British Pound\n");
printf("[3] European Euro\n");
printf("[4] Swiss Franc\n");
printf("[5] Japanese Yen\n");
printf("\n");
scanf("%d", &input);
/*switching statements */
switch (input)
{
case 1 :
printf("%1.6f Canadian Dollars is equal to %1.1f US Dollar.\n", CAD,USD);
break;
case 2 :
printf("%1.6f European Euro is equal to %1.1f US Dollar.\n", EUR,USD);
break;
case 3 :
printf("%1.6f British Pound is equal to %1.1f US Dollar.\n", GBP,USD);
break;
case 4 :
printf("%1.6f Swiss Franc is equal to %1.1f US Dollar.\n", CHF,USD);
break;
case 5 :
printf("%1.6f Japanese Yen is equal to %1.1f US Dollar.\n", YEN,USD);
break;
}
scanf("%d");
return 0;
}