Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main() {
- /* takes user inputs */
- int gbp_to_convert;
- char * USD, EUR, BRL, JPY, TRY, GBP;
- char * currency_to_convert_to;
- char is_staff;
- /* gets amount to convert in GBP */
- printf("please enter an amount to convert, less then 2500: ");
- scanf("%d", &gbp_to_convert);
- /* gets the currency to convert to */
- printf("please enter the currency you wish to convert to [USD/EUR/BRL/JPY/TRY]: ");
- scanf("%s", currency_to_convert_to);
- /* checks if the customer is staff */
- printf("is this customer staff? [Y/n]: ");
- scanf("%s", &is_staff);
- /* performs sanity checks on currencies */
- if(gbp_to_convert > 2500) {
- printf("you can only convert 2500 gbp in one transaction");
- return 1;
- }
- /* checks the currency */
- if(strcmp(currency_to_convert_to, "USD") == 0) {
- printf("USD");
- }
- else if(strcmp(currency_to_convert_to, "EUR") == 0) {
- printf("EUR");
- }
- else if(strcmp(currency_to_convert_to, "BRL") == 0) {
- printf("BRL");
- }
- else if(strcmp(currency_to_convert_to, "JPY") == 0) {
- printf("JPY");
- }
- else if(strcmp(currency_to_convert_to, "TRY") == 0) {
- printf("TRY");
- }
- else if(strcmp(currency_to_convert_to, "GBP") == 0) {
- printf("error, you can not convert GBP to GBP");
- return 1;
- }
- else {
- printf("invaild currency entered");
- return 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement