URI Online Judge Solution 1021 Banknotes and Coins – URI 1021 Solution in C, C++, Java, Python and C#
URI Online Judge Solution 1021 Banknotes and Coins | Beginner
URI Problem Link – URI 1021 Banknotes and Coins Problem – https://www.urionlinejudge.com.br/judge/en/problems/view/1021
Problem Name: 1021 Banknotes and Coins code
Problem Number : URI – 1021 Banknotes and Coins solution
Online Judge : URI Online Judge Solution
Category: Beginner
Solution Language : C,C plus plus, java, python, c#(c sharp)
URI Solution 1021 Banknotes and Coins Code in C / URI 1021 solution in C:
#include <stdio.h>
int main() {
int n100, n50, n20, n10, n5, n2;
int m1, m50, m25, m10, m05, m01;
double n;
scanf("%lf", &n);
int notas = n;
int moedas = (n - notas) * 100;
if((moedas * 1000) % 10 == 9){
moedas++;
}
n100 = notas/100;
notas = notas%100;
n50 = notas/50;
notas = notas%50;
n20 = notas/20;
notas = notas%20;
n10 = notas/10;
notas = notas%10;
n5 = notas/5;
notas = notas%5;
n2 = notas/2;
notas = notas%2;
m1 = notas/1;
notas = notas%1;
m50 = moedas/50;
moedas = moedas%50;
m25 = moedas/25;
moedas = moedas%25;
m10 = moedas/10;
moedas = moedas%10;
m05 = moedas/5;
moedas = moedas%5;
m01 = moedas/1;
printf("NOTAS:n");
printf("%d nota(s) de R$ 100.00n", n100);
printf("%d nota(s) de R$ 50.00n", n50);
printf("%d nota(s) de R$ 20.00n", n20);
printf("%d nota(s) de R$ 10.00n", n10);
printf("%d nota(s) de R$ 5.00n", n5);
printf("%d nota(s) de R$ 2.00n", n2);
printf("MOEDAS:n");
printf("%d moeda(s) de R$ 1.00n", m1);
printf("%d moeda(s) de R$ 0.50n", m50);
printf("%d moeda(s) de R$ 0.25n", m25);
printf("%d moeda(s) de R$ 0.10n", m10);
printf("%d moeda(s) de R$ 0.05n", m05);
printf("%d moeda(s) de R$ 0.01n", m01);
return 0;
}
Run Live URI 1021 C code and check [Give Test Input 576.73 to test first result]
URI Solution 1021 Banknotes and Coins Code / URI 1002 solution in CPP:
#include <iostream>
using namespace std;
int main() {
double n100, n50, n20, n10, n5, n2;
double m1, m50, m25, m10, m05, m01;
double n;
cin >> n;
int notas = n;
int moedas = (n - notas) * 100;
if((moedas * 1000) % 10 == 9){
moedas++;
}
n100 = notas/100;
notas = notas%100;
n50 = notas/50;
notas = notas%50;
n20 = notas/20;
notas = notas%20;
n10 = notas/10;
notas = notas%10;
n5 = notas/5;
notas = notas%5;
n2 = notas/2;
notas = notas%2;
m1 = notas/1;
notas = notas%1;
m50 = moedas/50;
moedas = moedas%50;
m25 = moedas/25;
moedas = moedas%25;
m10 = moedas/10;
moedas = moedas%10;
m05 = moedas/5;
moedas = moedas%5;
m01 = moedas/1;
cout << "NOTAS:" << endl;
cout << n100 << " nota(s) de R$ 100.00" << endl;
cout << n50 << " nota(s) de R$ 50.00" << endl;
cout << n20 << " nota(s) de R$ 20.00" << endl;
cout << n10 << " nota(s) de R$ 10.00" << endl;
cout << n5 << " nota(s) de R$ 5.00" << endl;
cout << n2 << " nota(s) de R$ 2.00" << endl;
cout << "MOEDAS:" << endl;
cout << m1 << " moeda(s) de R$ 1.00" << endl;
cout << m50 << " moeda(s) de R$ 0.50" << endl;
cout << m25 << " moeda(s) de R$ 0.25" << endl;
cout << m10 << " moeda(s) de R$ 0.10" << endl;
cout << m05 << " moeda(s) de R$ 0.05" << endl;
cout << m01 << " moeda(s) de R$ 0.01" << endl;
return 0;
}
URI Solution 1021 Banknotes and Coins Code / URI 1021 Banknotes and Coins solution in Java:
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
float x;
int note100,note50,note20,note10,note5,note2;
int moeda1,moeda5,moeda25,moeda10,moeda05,moeda01;
int reminder100;
Scanner input=new Scanner(System.in);
x = input.nextFloat();
note100 =(int) x / 100;
reminder100 = (int) (x % 100);
note50 = (reminder100) / 50;
note20 = (reminder100 % 50 )/ 20;
note10 = ((reminder100 % 50 )% 20) / 10;
note5 = (((reminder100 % 50 )% 20) % 10) / 5;
note2 = (((reminder100 % 50 )% 20) % 5) / 2;
//------ MOEDAS: ------------//
moeda1 = (((((reminder100 % 50 )% 20) % 5) % 2) / 1);
float reminderMoeda = (float) (((((reminder100 % 50 )% 20) % 5) % 2));
float meda5Float = (float) ((reminderMoeda % 1) / .5);
moeda5 = (int) (meda5Float);
moeda25 = (int) (((((((reminder100 % 50 )% 20) % 5) % 2) % 1) % .5) / .25);
moeda10 = (int) ((((((((reminder100 % 50 )% 20) % 5) % 2) % 1) % .5) % .25) / .1);
moeda05 = (int) (((((((((reminder100 % 50 )% 20) % 5) % 2) % 1) % .5) % .25) % .1) / .05);
moeda01 = (int) ((((((((((reminder100 % 50 )% 20) % 5) % 2) % 1) % .5) % .25) % .1) % .05) / .01);
System.out.print("NOTAS:n");
System.out.print(note100 +" nota(s) de R$ 100.00n");
System.out.print(note50 +" nota(s) de R$ 50.00n");
System.out.print(note20 +" nota(s) de R$ 20.00n");
System.out.print(note10 +" nota(s) de R$ 10.00n");
System.out.print(note5 +" nota(s) de R$ 5.00n");
System.out.print(note2 +" nota(s) de R$ 2.00nn");
System.out.print("MOEDAS:n");
System.out.print(moeda1 +" moeda(s) de R$ 1.00n");
System.out.print(meda5Float +" moeda(s) de R$ 0.50n");
System.out.print(moeda25 +" moeda(s) de R$ 0.25n");
System.out.print(moeda10 +" moeda(s) de R$ 0.10n");
System.out.print(moeda05 +" moeda(s) de R$ 0.05n");
System.out.print(moeda01 +" moeda(s) de R$ 0.01n");
}
}
URI Solution 1021Code / URI 1021 Banknotes and Coins solution in Python:
value = eval(input());
cem = cinquenta = vinte = dez = cinco = dois = um = 0;
cincents = vintecincents = dezcents = cincocents = cents = 0;
value = float("%.2f" % value)
if int(value/100) >= 1:
cem = int(value/100);
value -= cem*100;
value = float("%.2f" % value)
if int(value/50) >= 1:
cinquenta = int(value/50);
value -= cinquenta*50;
value = float("%.2f" % value)
if int(value/20) >= 1:
vinte = int(value/20.00);
value -= vinte*20;
value = float("%.2f" % value)
if int(value/10) >= 1:
dez = int(value/10);
value -= dez*10.00;
value = float("%.2f" % value)
if int(value/5) >= 1:
cinco = int(value/5);
value -= cinco*5;
value = float("%.2f" % value)
if int(value/2) >= 1:
dois = int(value/2);
value -= dois*2;
value = float("%.2f" % value)
if int(value/1) >= 1:
um = int(value/1);
value -= um*1;
value = float("%.2f" % value)
if int(value/0.50) >= 1:
cincents = int(value/0.50);
value -= cincents*0.50;
value = float("%.2f" % value)
if int(value/0.25) >= 1:
vintecincents = int(value/0.25);
value -= vintecincents*0.25;
value = float("%.2f" % value)
if int(value/0.10) >= 1:
dezcents = int(value/0.10);
value -= dezcents*0.10;
value = float("%.2f" % value)
if int(value/0.05) >= 1:
cincocents = int(value/0.05);
value -= cincocents*0.05;
value = float("%.2f" % value)
if int(value/0.01) >= 0.998:
cents = int(value/0.01);
value -= cents*0.01;
print("NOTAS:");
print("%d nota(s) de R$ 100.00" % cem);
print("%d nota(s) de R$ 50.00" % cinquenta);
print("%d nota(s) de R$ 20.00" % vinte);
print("%d nota(s) de R$ 10.00" % dez);
print("%d nota(s) de R$ 5.00" % cinco);
print("%d nota(s) de R$ 2.00" % dois);
print("MOEDAS:");
print("%d moeda(s) de R$ 1.00" % um);
print("%d moeda(s) de R$ 0.50" % cincents);
print("%d moeda(s) de R$ 0.25" % vintecincents);
print("%d moeda(s) de R$ 0.10" % dezcents);
print("%d moeda(s) de R$ 0.05" % cincocents);
print("%d moeda(s) de R$ 0.01" % cents);
URI Solution 1021Code / URI 1021 Banknotes and Coins solution in C# (C Sharp):
Demonstration:
It’s a problem of URI online Judge to convert notes. Use reminder to get the notes part and try..
Just implement this in coding. Since having any problem just put a comment below. Thanks
Tags: URI Online Judge Solution, URI OJ Solution list, URI Problems Solution, URI solver, URI all problem solution list, URI Banknotes and Coins code in C, URI 1021 code in C++, URI Banknotes and Coins solution in C, URI solution, URI 1021 Banknotes and Coins solution in C,URI 1021 Banknotes and Coins solution in C++-CPP,URI 1021 solution in C# (C sharp),URI 1021 Banknotes and Coins solution in Java,URI 1021 Banknotes and Coins solution in Python,