211k views
21 votes
2) Please create a C program for the following: (25 points) a. Suppose the US dollar to Korean Won is 0.85 dollars to 1000 won. Ask the user how many won is currently within their wallet / purse. Print out how much the Won is worth in US dollars, Indian Rupee (0.014 to the dollar), Jordanian Dinar (1.41 to the dollar) and Mexican Peso (0.048 to the dollar). You may also add another country of your choosing.

User Ghulam Ali
by
4.3k points

1 Answer

7 votes

Answer:

In C:

#include <stdio.h>

int main(){

float won,usd,rupee,dinar,peso;

printf("Won: ");

scanf("%f", &won);

usd = won * 0.85/1000;

rupee = won * 0.85 * 0.14/1000;

dinar = won * 0.85 * 0.048/1000;

peso = won * 0.85 * 1.41/1000;

printf("USD = %f\\", usd);

printf("Rupee = %f\\", rupee);

printf("Dinar = %f\\", dinar);

printf("Peso = %f\\", peso);

return 0;

}

Step-by-step explanation:

This declares all variables as float

float won,usd,rupee,dinar,peso;

This prompts the user for Korean Won

printf("Won: ");

This gets the input for won

scanf("%f", &won);

This converts to usd

usd = won * 0.85/1000;

This converts to rupee

rupee = won * 0.85 * 0.14/1000;

This converts to dinar

dinar = won * 0.85 * 0.048/1000;

This converts to peso

peso = won * 0.85 * 1.41/1000;

The next four lines print the converted currencies

printf("USD = %f\\", usd);

printf("Rupee = %f\\", rupee);

printf("Dinar = %f\\", dinar);

printf("Peso = %f\\", peso);

User Perh
by
4.3k points