#include<stdio.h>
3: #include<conio.h>
4:
5: float convert(float pesoValue, int choice, float amount);
6: void display(int choice, float result);
7:
8: int main()
9: {
10: int choice;
11: float pesoValue, amount, result = 0.0;
12:
13: printf("USD 1 is equivalent to Php ");
14: scanf("%f", &pesoValue);
15: printf("\nPress 1 for PESO to DOLLAR conversion\nPress 2 for DOLLAR to PESO conversion\n");
16:
17: while(1){
18: printf("\nChoice: ");
19: scanf("%d", &choice);
20: if( choice == 0)
21: return 0;
22: printf("Amount: ");
23: scanf("%f", &amount);
24: result = convert(pesoValue, choice, amount);
25: display(choice, result);
26: }
27:
28: getch();
29: }
30:
31: float convert(float pesoValue, int choice, float amount)
32: {
33: float result = 0.0;
34:
35: switch(choice){
36:
37: case 1:
38: result = amount / pesoValue;
39: break;
40: case 2:
41: result = amount * pesoValue;
42: break;
43: default:
44: break;
45: }
46:
47: return result;
48: }
49:
50: void display(int choice, float result)
51: {
52: switch(choice){
53:
54: case 1:
55: printf(">USD %.2f\n", result); break;
56: case 2:
57: printf(">Php %.2f\n", result); break;
58: default:
59: printf(">Invalid Input\n");
60: }
61: }