Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <string.h>
  5.  
  6. int main()
  7. {
  8. float coinsValue, notesValue, totalMoney;
  9. int switchValue;
  10. char originalMoney, convertedMoney;
  11.  
  12. printf("Enter original money typen");
  13. scanf("%c",&originalMoney);
  14.  
  15. printf("Enter the type of money you want to convertn");
  16. scanf("%c",&convertedMoney);
  17.  
  18. if (strcmp(originalMoney, "REAL") == 0 && strcmp(convertedMoney, "DOLLAR") == 0){
  19. switchValue = 1;
  20. } else if (strcmp(originalMoney, "REAL") == 0 && strcmp(convertedMoney, "LIBRAS")){
  21. switchValue = 2;
  22. } else if (strcmp(originalMoney, "DOLLAR") == 0 && strcmp(convertedMoney, "REAL")){
  23. switchValue = 3;
  24. } else if (strcmp(originalMoney, "DOLLAR") == 0 && strcmp(convertedMoney, "LIBRAS")){
  25. switchValue = 4;
  26. } else if (strcmp(originalMoney, "LIBRAS") == 0 && strcmp(convertedMoney, "REAL")){
  27. switchValue = 5;
  28. } else if (strcmp(originalMoney, "LIBRAS") == 0 && strcmp(convertedMoney, "DOLLAR")){
  29. switchValue = 6;
  30. } else {
  31. printf("You have chosen an invalid conversion option!");
  32. }
  33.  
  34. switch (switchValue) {
  35. case 1:
  36. printf("Entering case 1...n");
  37.  
  38. printf("Enter coins value in R$: n");
  39. scanf("%f",coinsValue);
  40.  
  41. printf("Enter notes value in R$: n");
  42. scanf("%f",notesValue);
  43.  
  44. totalMoney = coinsValue + notesValue;
  45. totalMoney = totalMoney * 4.01;
  46.  
  47. printf("The value in reais converted to dollar is: %.2f",totalMoney);
  48. break;
  49. case 2:
  50. printf("Entering case 2...n");
  51. break;
  52. case 3:
  53. printf("Entering case 3...n");
  54. break;
  55. case 4:
  56. printf("Entering case 4...n");
  57. break;
  58. case 5:
  59. printf("Entering case 5...n");
  60. break;
  61. case 6:
  62. printf("Entering case 6...n");
  63. break;
  64. }
  65. return 0;
  66. }
  67.  
  68. char originalMoney[10];
  69. scanf("%s9", &originalMoney);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement