Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

error: could not convert ‘total’ from ‘int’ to ‘std::string’

$
0
0

I was trying to make a currency converter from pln to either usd or euros. However I keep getting the error

could not convert ‘total’ from ‘int’ to ‘std::string’

How do you suggest I fix it and what did I write wrong in the code below?

#include <iostream>using namespace std;int converting(string convertcurrency, int pln, int total){    if (convertcurrency=="dollars")        total = pln * 0.22;    else        total = pln * 0.25;    return total;}int main(){  cout<<"Welcome to my currency converter program! There are currently two choices of currency to convert to from PLN: euros (€) and us dollars ($). \n\n";  int pln;  int total;  string convertcurrency;  cout<<"Please input the amount of PLN you'd like to convert. ";  cin >> pln;  cout<<"Which currency would you like to convert " << pln << "PLN to? (euros/dollars) ";  cin >> convertcurrency;  /*cout << Euc_ver2(a, b);  return 0;*/  cout << "Converting " << pln << "PLN to " << convertcurrency << ". . . \n";  cout << converting(total) << convertcurrency;  return 0;}

Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>