1

My program is a currency converter. Currently, my code works to convert currency but if the user were to type in characters rather than a number, it enters an infinite loop. This is the part of my code that I need to add something to verify the data.

void menu_item_4() {
  std::cout << "\n>> EUR to GBP\n";
  std::cout << "\nEnter a value to convert from EUR to GBP\n";
  float EUR_GBP;
  std::cin >> EUR_GBP;
  float eur_gbp = EUR_GBP * 0.86;
  std::cout << EUR_GBP << " EUR is equal to " << eur_gbp << " GBP.";
  go_back_to_main();
}

Let me know what I can do.

Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111

0 Answers0