Write the "bankruptcy breakdown" method that requests an integer value and returns the corresponding amount of tickets. The tickets used are: $ 1, $ 5, $ 10, $ 20, $ 50, $ 100 Example: amount = 157 {$ 100 (1), $ 50 (1), $ 5 (1), $ 1 (2)}
This is the code that I have tried to return functional at the moment, although I know that it has many obvious logical errors. (It's from a third party and I'm only doing him the favor because he does not know how to occupy much that we follow the forum)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Alfredo
{
class Program
{
static void Main(string[] args)
{
//Declaracion de variables
Double Dinero, B1 = 0, B5 = 0, B10 = 0, B20 = 0, B50 = 0, B100 = 0;
//Entrada de datos
Console.WriteLine("Ingrese la cantidad de dinero a desglosar: ");
Dinero = Convert.ToDouble(Console.ReadLine());
//Proceso
if (Dinero >= 100)
B100 = Math.Abs(Dinero) / 100;
Dinero = Dinero - (B100 * 100);
if (Dinero >= 50)
B50 = Math.Abs(Dinero) / 50;
Dinero = Dinero - (B100 * 50);
if (Dinero >= 20)
B100 = Math.Abs(Dinero) / 20;
Dinero = Dinero - (B20 * 20);
if (Dinero >= 10)
B10 = Math.Abs(Dinero) / 10;
Dinero = Dinero - (B10 * 10);
if (Dinero >= 5)
B5 = Math.Abs(Dinero) / 5;
Dinero = Dinero - (B5 * 5);
if (Dinero >= 1)
B1 = Math.Abs(Dinero) / 1;
Dinero = Dinero - (B1 * 1);
//Salida
Console.WriteLine("La cantidad en billetes de $100: " + B100);
Console.WriteLine("La cantidad en billetes de $50: " + B50);
Console.WriteLine("La cantidad en billetes de $20: " + B20);
Console.WriteLine("La cantidad en billetes de $10: " + B10);
Console.WriteLine("La cantidad en billetes de $5: " + B5);
Console.WriteLine("La cantidad en billetes de $1: " + B1);
Console.ReadLine();
}
}
}