Peso Converter
Peso Converter demonstrate the conversion of peso to other currency, the Switch Case Structures and Arrays applied on this code.
OUTPUT
#include<stdio.h>
#include<stdlib.h>
int main()
{
int choice;
char dollar[20]="American Dollar";
char BP[20]="Bristish Pound";
char HK[20]="Hong Kong Dollar";
char JY[20]="Japanese Yen";
char KW[20]="Korean Won";
char SLR[20]="Sri Lanka Rupee";
float php,USD,Pound,HKD,Yen,Won,Rupee;
sys('cls');
printf("Peso Converter\n");
printf("\n[1] American Dollar - 47.44");
printf("\n[2] Bristish Pound - 71.97");
printf("\n[3] Hong Kong Dollar - 6.12");
printf("\n[4] Japanese Yen - 0.39");
printf("\n[5] Korean Won - 0.040");
printf("\n[6] Sri Lanka Rupee - 0.33");
printf("\n\nEnter your currency: ");
scanf("%d",&choice);
printf("\n\nEnter your peso Amount: ");
scanf("%f" ,&php);
switch(choice)
{
case 1: printf("You have chosen %s",dollar);
USD=php*47.44;
printf("\nAnd Your peso bill is equivalent to %.2f %s",USD,dollar);
break;
case 2: printf("You have chosen %s",BP);
Pound=php*71.97;
printf("\nAnd Your peso bill is equivalent to %.2f %s",Pound,BP);
break;
case 3: printf("You have chosen %s",HK);
HKD=php*6.12;
printf("\nAnd Your peso bill is equivalent to %.2f %s",HKD,HK);
break;
case 4: printf("You have chosen %s",JY);
Yen=php*0.39;
printf("\nAnd Your peso bill is equivalent to %.2f %s",Yen,JY);
break;
case 5: printf("You have chosen %s",KW);
Won=php*0.040;
printf("\nAnd Your peso bill is equivalent to %.2f %s",Won,KW);
break;
case 6: printf("You have chosen %s",SLR);
Rupee=php* 0.33;
printf("\nAnd Your peso bill is equivalent to %.2f %s",Rupee,SLR);
break;
default:
printf("Invalid Choice!\n");
break;
}
printf("\n\nThank you for using the Peso Converter.\n\n");
system("pause");
return 0;
}
Peso Converter
Reviewed by code-dev
on
3:57 PM
Rating:
No comments: