URI Online Judge Solution 1021 Banknotes and Coins - URI 1021 Solution in C, C++, Java, Python and C# - Online Judge Solution

Latest

It is a free Online judges problems solution list. Here you can find UVA online Judge Solution, URI Online Judge Solution, Code Marshal Online Judge Solution, Spoz Online Judge Problems Solution

Thursday, June 8, 2017

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 - 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 Online Judge Solution 1021 Banknotes and Coins - URI 1021 Solution in C, C++, Java, Python and C#


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.00\n", n100);
    printf("%d nota(s) de R$ 50.00\n", n50);
    printf("%d nota(s) de R$ 20.00\n", n20);
    printf("%d nota(s) de R$ 10.00\n", n10);
    printf("%d nota(s) de R$ 5.00\n", n5);
    printf("%d nota(s) de R$ 2.00\n", n2);

    printf("MOEDAS:\n");

    printf("%d moeda(s) de R$ 1.00\n", m1);
    printf("%d moeda(s) de R$ 0.50\n", m50);
    printf("%d moeda(s) de R$ 0.25\n", m25);
    printf("%d moeda(s) de R$ 0.10\n", m10);
    printf("%d moeda(s) de R$ 0.05\n", m05);
    printf("%d moeda(s) de R$ 0.01\n", 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.00\n");
        System.out.print(note50 +" nota(s) de R$ 50.00\n");
        System.out.print(note20 +" nota(s) de R$ 20.00\n");
        System.out.print(note10 +" nota(s) de R$ 10.00\n");
        System.out.print(note5 +" nota(s) de R$ 5.00\n");
        System.out.print(note2 +" nota(s) de R$ 2.00\n\n");

        System.out.print("MOEDAS:\n");
        System.out.print(moeda1 +" moeda(s) de R$ 1.00\n");
        System.out.print(meda5Float +" moeda(s) de R$ 0.50\n");
        System.out.print(moeda25 +" moeda(s) de R$ 0.25\n");
        System.out.print(moeda10 +" moeda(s) de R$ 0.10\n");
        System.out.print(moeda05 +" moeda(s) de R$ 0.05\n");
        System.out.print(moeda01 +" moeda(s) de R$ 0.01\n");

    }

}

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,

3 comments:

  1. Can you please explain the following block of code?

    cin >> n;
    int notas = n;
    int moedas = (n - notas) * 100;

    if((moedas * 1000) % 10 == 9){
    moedas++;
    }

    ReplyDelete
  2. Is your Blockchain account not working properly or you are unable to open your account? Is it because your account has been hacked by someone? If you suspect any hacking activity in your account, you can directly contact the team anytime and avail solutions related to queries. All you have to do is call on Blockchain phone number which is available and every user across the world call on this number to eradicate errors going on in the account.

    ReplyDelete
  3. import java.util.*;
    public class Main
    {
    public static void main(String[] args) {
    Scanner scan=new Scanner(System.in);

    double amount = scan.nextDouble();

    int hundred = (int)(amount/100);
    int fifty = (int)((amount % 100)/50);
    int twenty = (int)((amount % 100 % 50)/20);
    int ten = (int)((amount % 100 % 50 % 20)/10);
    int five = (int)((amount % 100 % 50 % 20 % 10)/5);
    int two = (int)((amount % 100 % 50 % 20 % 10 % 5)/2);


    int one = (int)((amount % 100 % 50 % 20 % 10 % 5 % 2)/1);
    int pointfifty = (int)((amount % 100 % 50 % 20 % 10 % 5 % 2 % 1)/0.50);
    int pointtwentyfive = (int)((amount % 100 % 50 % 20 % 10 % 5 % 2 % 1 % 0.50)/0.25);
    int pointten = (int)((amount % 100 % 50 % 20 % 10 % 5 % 2 % 1 % 0.50 % 0.25)/0.10);
    int poinfive = (int)((amount % 100 % 50 % 20 % 10 % 5 % 2 % 1 % 0.50 % 0.25 % 0.10)/0.05);
    int pointone = (int)((amount % 100 % 50 % 20 % 10 % 5 % 2 % 1 % 0.50 % 0.25 % 0.10 % 0.05)/0.01);

    System.out.println("NOTAS:");
    System.out.println(hundred +" nota(s) de R$ 100.00");
    System.out.println(fifty +" nota(s) de R$ 50.00");
    System.out.println(twenty +" nota(s) de R$ 20.00");
    System.out.println(ten +" nota(s) de R$ 10.00");
    System.out.println(five +" nota(s) de R$ 5.00");
    System.out.println( two+" nota(s) de R$ 2.00");
    System.out.println("MOEDAS:");
    System.out.println(one +" moeda(s) de R$ 1.00");
    System.out.println(pointfifty +" moeda(s) de R$ 0.50");
    System.out.println(pointtwentyfive +" moeda(s) de R$ 0.25");
    System.out.println(pointten +" moeda(s) de R$ 0.10");
    System.out.println(poinfive +" moeda(s) de R$ 0.05");
    System.out.println(pointone +" moeda(s) de R$ 0.01");

    }
    }
    explain me why my code is wrong???

    ReplyDelete