Okay so classes got out a month ago and fall semester starts back up in 3 weeks. I wanted to do the homework in the book that we were never assigned. This one question gotta got me stuck because its in the second chapter. Its a program to give change back (the 92 cents is a compile time initialization). My question is... Is there any way to make this program more "dummy downed" than it is. And also I had to put (int) in front of my assignment of what anQuarter, anDime, etc were. Otherwise I was getting decimals afterwards. Why is that? Can an experienced programmer explain?
Also, the chapter talked about MOD so that is why I used it. This is before calling class methods are introduced and obviously before loops and arrays. So I couldnt use any of those tools. Supposed to be just a very basic "cave man" program...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication273
{
class Program
{
static void Main(string[] args)
{
double change = 0.92;
double quarter = 0.25;
double dime = 0.10;
double nickel = 0.05;
double pennies = 0.01;
double anQuarter = (int)(change / quarter);
double anDime = (int)((change % quarter) / dime);
double anNickel = (int)(((change % quarter) % dime) / nickel);
double anPennies = (int)((((change % quarter) % dime) % nickel) / pennies);
Console.WriteLine("The amount of quarters are....{0}", anQuarter);
Console.WriteLine("The amount of dimes are....{0}", anDime);
Console.WriteLine("The amount of nickels are....{0}", anNickel);
Console.WriteLine("The amount of pennies are....{0}", anPennies);
}
}
}