n automated donation machine accepts donations via 10 or 20 bills to a maximum of $990. The machine needs to print a receipt with the donation amount in English, rather than numerically. Complete the following function which converts any number between 10 to 990 dollars to English. NOTE: You may define and use another function if necessary. NOTE: You should use arrays for this task. Use of switch statements or very long if/else if statements for printing is not allowed. However, using if/else if/else statements for the logic of your algorithm is permitted.
An automated donation machine accepts donations via 10 or 20 bills to a maximum of $990.
The machine needs to print a receipt with the donation amount in English, rather than numerically. Complete the following function which converts any number between 10 to 990 dollars to English.
NOTE: You may define and use another function if necessary.
NOTE: You should use arrays for this task. Use of switch statements or very long if/else if statements for printing is not allowed. However, using if/else if/else statements for the logic of your
NOTE: This function returns the result, and does not print it. Make sure the result is not lost when you return.
Example function input and output (donation is 110):
Input: 110
Output: “one hundred ten dollars”
string convertToEnglish (int donation);
in C++
#include <iostream>
#include <string>
using namespace std;
string convertToEnglish (int donation);
int main() {
int donation;
cin>>donation;
cout<<convertToEnglish(donation);
return 0;
}
string convertToEnglish (int donation)
{
//Put your code here
return "the result of your conversion";
}
Step by step
Solved in 3 steps with 1 images