Write a program named, coins.cpp. After displaying a brief description of what this program will do, the program will prompt and get from the user an integer representing a number of cents. The program should assume that this number is greater than zero, but no
maximum will be assumed. The program should next determine the smallest number of coins needed to represent the number of cents input by the user. The program will ONLY use the following coins: dollars, quarters, dimes, nickels, and pennies. This program does not require and should NOT use any if-statements, nor should it use any
loop statements. All that is needed are the integer division operator and the remainder operator. The textbook discusses these
operators. When the numbers of coins have been determined, each is displayed along with the total number of
coins needed. Your output should be formatted like the examples below, but should work properly for any valid input by the user.
Example 1:
This application will calculate the smallest number of coins needed to represent a cents value. Enter a number of cents: 79 7 coins are needed to represent 79 cents: Dollars: 0 Quarters: 3 Dimes: 0 Nickels: 0 Pennies: 4 End of Least Coins App
Expert Answer
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
int quarter,dime,dollar,nickel,penny, cents;
int cent = cents;
cout << “This application will calculate the smallest number of coins needed to represent a cents value.”;
cout << “nEnter a number of cents: “;
cin >> cents;
dollar = cents/100;
cents = cents – 100*dollar;
quarter = cents/25;
cents = cents – 25*quarter;
dime = cents/10;
cents = cents – 10*dime;
nickel = cents/5;
cents = cents – 5*nickel;
penny = cents;
cout << “coins are needed to represent ” << cent << ” centsn”;
cout << “Dollars: ” << dollar << endl;
cout << “Quarters: ” << quarter << endl;
cout << “Dimes: ” << dime << endl;
cout << “Nickels: ” << nickel << endl;
cout << “Pennies: ” << penny << endl;
cout << “End of Least Coins Appn”;
return 0;
}