Repo for Programming MB code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1006 B

  1. #include <iostream>
  2. using namespace std;
  3. int convert()
  4. {
  5. double orig;
  6. double converted;
  7. int currency;
  8. cout << "Enter the original amount (USD): ";
  9. cin >> orig;
  10. cout << "Enter the currency to convert to (1 = peso, 2 = rupee, 3 = pound, 4 = euro): ";
  11. cin >> currency;
  12. switch(currency) {
  13. case 1 :
  14. converted = orig * 22.4;
  15. break;
  16. case 2:
  17. converted = orig * 75.69;
  18. break;
  19. case 3:
  20. converted = orig * 0.8;
  21. break;
  22. case 4:
  23. converted = orig * 0.89;
  24. break;
  25. default:
  26. cout << "Invalid value" << endl;
  27. }
  28. cout << "The converted value is: " << converted << endl;
  29. return 1;
  30. }
  31. int main()
  32. {
  33. char cont = 'y';
  34. while(cont == 'y'){
  35. convert();
  36. cout << endl;
  37. cout << "Would you like to continue? Enter y or n: ";
  38. cin >> cont;
  39. }
  40. return 0;
  41. }