Computer Science, asked by ak9528991, 1 day ago

Faisal bank need a ATM machine. In this machine they need to add all possible currency divisions (1, 2 10, 20, 50, 100, 500, 1000, 5000). Write a C++ program in which, take required amount from user and f the required currency division which will give to user in order to pay the required amount. Example: Sample input: Enter required amount: 7895 Required currency division is: 5000:1 1000: 2 500:1 100: 3 50:1 20:2 10:0 5:1 2: 0 1:0​

Answers

Answered by elavarasidharshini51
0

Answer:

Please Mark Me As A Brainlist

Explanation:

#include <iostream>

#include <iomanip>

using namespace std;

int main() {

int nominals[10] = {1, 2, 5, 10, 20, 50, 100, 500, 1000, 5000};

int banknotes[10] = {0};

int amount;

cout << "Enter an amout to be payed: ";

cin >> amount;

if (amount <= 0) {

cout << "Incorrect input" << endl;

return 0;

}

int i = 9;

while (amount > 0) {

if (amount < nominals[i]) {

i--;

continue;

}

amount -= nominals[i];

banknotes[i]++;

}

cout << endl;

cout << "nominal | number" << endl;

for (i=9; i>=0; i--) {

if (banknotes[i] > 0) {

cout << " " << setw(4) << nominals[i] << " | " << banknotes[i] << endl;

}

}

}

Similar questions