Write a program that prints the number of quarters, dimes, nickels, and pennies that a customer should get back as change. Run your program once by performing a compile-time initialization using 92 cents for the value to be converted. Go into your source code and change the 92 to 27. Rerun the application.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Correct_change
{
class Program
{
static void Main(string[] args)
{
int totalCents;
String strCents;
Console.WriteLine("Enter total number of cents:");
strCents = Console.ReadLine();
totalCents = Int32.Parse(strCents);
int quarters = totalCents / 25;
totalCents %= 25;
int dimes = totalCents / 10;
totalCents %= 10;
int nickels = totalCents / 5;
int pennies = totalCents % 5;
Console.WriteLine("quarters :"+quarters+"\ndimes :"+dimes
+"\nnickels :"+nickels+"\npennies :"+pennies);
Console.ReadKey();
}
}
}
Output:
Enter total number of cents:
92
quarters :3
dimes :1
nickels :1
pennies :2
Enter total number of cents:
27
quarters :1
dimes :0
nickels :0
pennies :2