Triple post, I know, but it helps me learn when I can go back and see what Ive done. Anyways, got it 100% done! Im sure its a bit crude, so what can I do to clean it up?
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Change_Thinger
{
class Program
{
static void Main(string[] args)
{
double money = 0;
string name1 = "Jordan"; // , name2 = "", name3 = "";
Console.WriteLine("How much did " + name1 + " make?");
Console.Write("$");
money = Convert.ToDouble(Console.ReadLine());
Console.WriteLine();
// take the total value, and keep subtracting the amount (100, 50, etc)
// until no more can be taken away (before going negative)
int h = -1;
while (money >= 0)
{
money = money - 100;
h++;
}
// somehow we end up with a negative, so add the original value back
money = money + 100;
int f = -1;
while (money >= 0)
{
money = money - 50;
f++;
}
money = money + 50;
int t = -1;
while (money >= 0)
{
money = money - 20;
t++;
}
money = money + 20;
int te = -1;
while (money >= 0)
{
money = money - 10;
te++;
}
money = money + 10;
int fi = -1;
while (money >= 0)
{
money = money - 5;
fi++;
}
money = money + 5;
int to = -1;
while (money >= 0)
{
money = money - 2;
to++;
}
money = money + 2;
int l = -1;
while (money >= 0)
{
money = money - 1;
l++;
}
money = money + 1;
int q = -1;
while (money >= 0)
{
money = money - .25;
q++;
}
money = money + .25;
int d = -1;
while (money >= 0)
{
money = money - .1;
d++;
}
money = money + .1;
int n = -1;
while (money >= 0)
{
money = money - .05;
n++;
}
money = money + .05;
int p = -1;
while (money >= 0)
{
money = money - .01;
p++;
}
money = money + .01;
Console.WriteLine("Hundreds: "+ h +"");
Console.WriteLine("Fifties: "+ f +"");
Console.WriteLine("Twenties: " + t +"");
Console.WriteLine("Tens: " + te +"");
Console.WriteLine("Fives: " + fi+"");
Console.WriteLine("Toonies: " + to +"");
Console.WriteLine("Loonies: " + l +"");
Console.WriteLine("Quarters: " + q +"");
Console.WriteLine("Dimes: " + d +"");
Console.WriteLine("Nickels: " + n +"");
Console.WriteLine("Pennies: " + p +"");
Console.ReadKey();
}
}
}