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.

55 lines
1.1 KiB

  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. bool cont = true;
  34. char contcheck;
  35. while(cont ){
  36. convert();
  37. cout << endl;
  38. cout << "Would you like to continue? Enter y or n: ";
  39. cin >> contcheck;
  40. if(contcheck = 'y'){
  41. cont = true;
  42. } else{
  43. cont = false;
  44. }
  45. }
  46. return 0;
  47. }