Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. int main() {
  4. /* takes user inputs */
  5. int gbp_to_convert;
  6. char * USD, EUR, BRL, JPY, TRY, GBP;
  7. char * currency_to_convert_to;
  8. char is_staff;
  9.  
  10. /* gets amount to convert in GBP */
  11. printf("please enter an amount to convert, less then 2500: ");
  12. scanf("%d", &gbp_to_convert);
  13.  
  14. /* gets the currency to convert to */
  15. printf("please enter the currency you wish to convert to [USD/EUR/BRL/JPY/TRY]: ");
  16. scanf("%s", currency_to_convert_to);
  17.  
  18. /* checks if the customer is staff */
  19. printf("is this customer staff? [Y/n]: ");
  20. scanf("%s", &is_staff);
  21.  
  22. /* performs sanity checks on currencies */
  23. if(gbp_to_convert > 2500) {
  24. printf("you can only convert 2500 gbp in one transaction");
  25. return 1;
  26. }
  27.  
  28.  
  29.  
  30. /* checks the currency */
  31. if(strcmp(currency_to_convert_to, "USD") == 0) {
  32. printf("USD");
  33.  
  34. }
  35. else if(strcmp(currency_to_convert_to, "EUR") == 0) {
  36. printf("EUR");
  37. }
  38. else if(strcmp(currency_to_convert_to, "BRL") == 0) {
  39. printf("BRL");
  40. }
  41. else if(strcmp(currency_to_convert_to, "JPY") == 0) {
  42. printf("JPY");
  43. }
  44. else if(strcmp(currency_to_convert_to, "TRY") == 0) {
  45. printf("TRY");
  46. }
  47. else if(strcmp(currency_to_convert_to, "GBP") == 0) {
  48. printf("error, you can not convert GBP to GBP");
  49. return 1;
  50. }
  51. else {
  52. printf("invaild currency entered");
  53. return 1;
  54. }
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement