Saturday, 20 September 2014

How do you make a program that helps a money converter determine the value of a person's money in the selected currency?

How do you make a program that helps a money converter determine the value of a person's money in the selected currency?
#include<stdio.h>
#include<string.h>
main()
char Peso='P';
char Dollar='USD';
char Euro='E';
char currency[5];
float amount=0;
char currency2[5];
float equivalent;

printf("In what currency is the person's money?nt(P)esont(USD)ollarnt(E)uron");
scanf("%s",currency);

printf("nWhat is the amount?n");
scanf("%f",&amount);

printf("nIn what currency do you want it changed?nt(P)esont(USD)ollarnt(E)uron");
scanf("%s",currency2);

if(strcmp(currency,"P")==0 && strcmp(currency2,"USD")==0)
equivalent=amount*0.0237;
printf("The equivalent of his money is P%.2f.nn",equivalent);

else if(strcmp(currency,"P")==0 && strcmp(currency2,"E")==0)
equivalent=amount*0.0187;
printf("The equivalent of his money is P%.2f.nn",equivalent);

else if(strcmp(currency,"USD")==0 && strcmp(currency2,"P")==0)
equivalent=amount*42.0006;
printf("The equivalent of his money is P%.0f.nn",equivalent);

else if(strcmp(currency,"USD")==0 && strcmp(currency2,"E")==0)
equivalent=amount*0.7874;
printf("The equivalent of his money is P%.2f.nn",equivalent);

else if(strcmp(currency,"E")==0 && strcmp(currency2,"P")==0)
equivalent=amount*53.4804;
printf("The equivalent of his money is P%.2f.nn",equivalent);

else if(strcmp(currency,"E")==0 && strcmp(currency2,"USD")==0)
equivalent=amount*1.27;
printf("The equivalent of his money is P%.2f.nn",equivalent);

else
printf("nWrong Input!nn");




#include<stdio.h>
#include<string.h>

main()
int SUV=3500;
int Car=2500;
int Motorcycle=900;
int Truck=4000;
char type[5];
char registration[5];
int ans;

printf("Please select the type of vehicle:ntS - SUVntC - CarntM - MotorcyclentT - Truckn");
scanf("%s",type);

if(strcmp(type,"S")==0 strcmp(type,"s")==0)
printf("nIs vehicle registered on time?Y/Nn");
scanf("%s",registration);
if(strcmp(registration,"Y")==0 strcmp(registration,"y")==0)
printf("nTotal Reaistration fee is P%d.nn",SUV);
else if(strcmp(registration,"N")==0 strcmp(registration,"n")==0)
ans=(3500*0.1)+3500;
printf("nTotal Registration fee is P%d.nn",ans);
else
printf("ninvalid!nn");
else if(strcmp(type,"C")==0 strcmp(type,"c")==0)
printf("nIs vehicle registered on time?Y/Nn");
scanf("%s",registration);
if(strcmp(registration,"Y")==0 strcmp(registration,"y")==0)
printf("nTotal Reaistration fee is P%d.nn",Car);
else if(strcmp(registration,"N")==0 strcmp(registration,"n")==0)
ans=(2500*0.1)+2500;
printf("nTotal Registration fee is P%d.nn",ans);
else
printf("ninvalid!nn");
else if(strcmp(type,"M")==0 strcmp(type,"m")==0)
printf("nIs vehicle registered on time?Y/Nn");
scanf("%s",registration);
if(strcmp(registration,"Y")==0 strcmp(registration,"y")==0)
printf("nTotal Reaistration fee is P%d.nn",Motorcycle);
else if(strcmp(registration,"N")==0 strcmp(registration,"n")==0)
ans=(900*0.1)+900;
printf("nTotal Registration fee is P%d.nn",ans);
else
printf("ninvalid!nn");
else if(strcmp(type,"T")==0 strcmp(type,"t")==0)
printf("nIs vehicle registered on time?Y/Nn");
scanf("%s",registration);
if(strcmp(registration,"Y")==0 strcmp(registration,"y")==0)
printf("nTotal Registration fee is P%d.nn",Truck);
else if(strcmp(registration,"N")==0 strcmp(registration,"n")==0)
ans=(4000*0.1)+4000;
printf("nTotal Registration fee is P%d.nn",ans);
else
printf("ninvalid!nn");
else
printf("nInvalid Input!nn");






#include<stdio.h>
#include<string.h>
main()
char status[5];
int numChildren;
int tax;
int i=1;

printf("Status of Person: S - Singlentt M - Marriedntt H - Head of the Familyn");
scanf("%s",status);

while(i<=status)
i++;

if(strcmp(status,"S")==0 strcmp(status,"s")==0)
tax=20000;
printf("nTotal Tax Exemption: P%dnn",tax);

else if(strcmp(status,"M")==0 strcmp(status,"m")==0)
printf("nNo. of Children Under 18:n");
scanf("%d",&numChildren);
if(numChildren>0)
tax=32000+(8000*numChildren);
printf("nTotal Tax Exemption: P%dnn",tax);
else
tax=32000;
printf("Total Tax Exemption: P%dnn",tax);


else if(strcmp(status,"H")==0 strcmp(status,"h")==0)
tax=25000;
printf("Total Tax Exemption: P%dnn",tax);

else
printf("nWrong Choice!nn");

No comments:

Post a Comment