Question: 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 $
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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
