Answer to Question #295548 in C++ for GgHrg

Question #295548

you should read this question if you change is given as ai based bankers write a c++ program that asks you to write a modular solution that will only accept an integer value of trains between 5 to 9 55 i was lotion should ensure that input value are in multiples of 5 based upon your input you should calculate it how many coins of each solution could be a statement and display the its uses. coin value 50, 20, 10, 5. the solutions of each coin should aim to give as much as higher value coin as possible


1
Expert's answer
2022-02-09T08:04:52-0500
#include<iostream>

using namespace std;

int main()
{
	int value;
	cout<<"Please, enter a value in multiples of 5: ";
	cin>>value;
	int coinValue[4]={0,0,0,0};
	while(value>=5)
	{
		if(value>=50)
		{
			coinValue[0]=value/50;
			value=value%50;
		}
		if(value>=20)
		{
			coinValue[1]=value/20;
			value=value%20;
		}
		if(value>=20)
		{
			coinValue[2]=value/10;
			value=value%10;
		}
		if(value>=5)
		{
			coinValue[3]=value/5;
			value=value%5;
		}
	}
	cout<<"You got:\n";
	if(coinValue[0]>0)
		cout<<coinValue[0]<<" notes of coin value 50\n";
	if(coinValue[1]>0)
		cout<<coinValue[1]<<" notes of coin value 20\n";
	if(coinValue[2]>0)
		cout<<coinValue[2]<<" notes of coin value 10\n";
	if(coinValue[3]>0)
		cout<<coinValue[3]<<" notes of coin value 5\n";
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog