Answers:
Following are the program in c++ language
#include<iostream> // header file
#include<string>// header file
using namespace std;// header file
int main() // main function
{
int q1,d1,n1,p1,sum,x,y; // variable declaration
cout << "Enter the number of quarters:";
cin >> q1; // Read the quarters value by user
cout << "Enter the number of dimes:";
cin >> d1;// Read the dimes value by user
cout << "Enter the number of nickels:";
cin >> n1;// Read the nickels value by user
cout << "Enter the number of pennies:";
cin >> p1;// Read the pennies value by user
sum = q1 * 25 + d1 *10 + n1 *5 + p1; // calculating
x = sum % 100; // calculating the amount of money
y = sum/100;//calculating the amount of money
cout << "The individual total value are " << q1 << " quarters , " << d1 << " dimes are, " << n1 << " nickes and " << p1 << " pennies is ";
cout << "$" << y<< "." << x << endl; // print in the dollar format
return 0;
}
Output:
Enter the number of quarters:2
Enter the number of dimes:3
Enter the number of nickels:4
Enter the number of pennies:5
The individual total value are 2 quarters, 3 dimes are, 4 nickes and 5 pennies is $1.25
Explanation:
Following are the description of the program
- Read the value of quarters,dimes,nickes and pennies in the q1,d1,n1 and p1 variable of int type
- After that calculating the amount of money
- Finally display the money in dollar