Suppose that the only currency were 3dollar bills and 10doll

Suppose that the only currency were 3-dollar bills and 10-dollar bills. Please write a program in C++ to determine the number of 3-dollar bills and the number of 10-dollar bills for any amount greater than $17.

Solution

#include <iostream>

using namespace std;

int main()
{
/*read bills amount greater than $17*/
int bill_amount;

/* initialize number of 3 dollor is zero */
int num_of_3_dollor=0;
/* initialize number of 10 dollor is zero */
int num_of_10_dollor=0;

cout << \"Enter bills amount greater than $17.\" << endl;
cout<<\"$\";

/*read bills amount greater than $17*/
cin>>bill_amount;

/*print message if amount is not greater than $17*/
if(bill_amount<18)
{
cout<<\"Enter bills amount greater than $17.\"<<endl<<endl;
return 0;

}

int bill_amount_for_3=bill_amount%10;
int bill_amount_for_10=bill_amount/10;

/* while bill_amount_for_3 not equal to 3 multiplication*/
while(((bill_amount_for_3)%3)!=0)
{
/*bill_amount_for_3 will be increased by 10*/
bill_amount_for_3=bill_amount_for_3+10;

/*Number of 10 dollor will be decrease by 1*/
bill_amount_for_10= bill_amount_for_10-1;

}

num_of_10_dollor=bill_amount_for_10;

/*num_of_3_dollor will be equal to bill_amount_for_3 divide by3;*/
num_of_3_dollor=bill_amount_for_3/3;

cout<<\" Number of 10 dollor ($) : \"<<num_of_10_dollor<<endl;
cout<<\" Number of 3 dollor ($) : \"<<num_of_3_dollor<<endl;

return 0;

}// end of main

==============================================================================

output example 1:-

Enter bills amount greater than $17.
$18
Number of 10 dollor ($) : 0
Number of 3 dollor ($) : 6

------------------------------

output example 2:-

Enter bills amount greater than $17.

$384
Number of 10 dollor ($) : 36
Number of 3 dollor ($) : 8

----------------------------------

output example 3:-

Enter bills amount greater than $17.
$58
Number of 10 dollor ($) : 4
Number of 3 dollor ($) : 6

----------------------------

output example 4:-

Enter bills amount greater than $17.
$15
Enter bills amount greater than $17.

---------------------------------------------------------------------------------------------

If you have any query, please feel free to ask

Thanks a lot

Suppose that the only currency were 3-dollar bills and 10-dollar bills. Please write a program in C++ to determine the number of 3-dollar bills and the number o
Suppose that the only currency were 3-dollar bills and 10-dollar bills. Please write a program in C++ to determine the number of 3-dollar bills and the number o

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site