Menu

Std String Displaymoney Int Amount Money Displayed Using Tostring Function Std String Doll Q43796671

std::string displayMoney(int amount)
{

// Here the money will be displayed using the to_string()function
std::string dollars{ std::to_string(amount/100) };
std::string cents{ std::to_string(std::abs(amount%100)) };

return “$” + dollars + “.” + (cents.size() == 1 ? “0” : “”) +cents;
}

HOW would i do this in the swift programming language

Expert Answer


Answer to std::string displayMoney(int amount) { // Here the money will be displayed using the to_string() function std::string d…

OR