Using Using Using Using Using Namespace: //GOAL: Calcualte The Change Needed in Quarters, Dimes, Nickles and Pennies
Using Using Using Using Using Namespace: //GOAL: Calcualte The Change Needed in Quarters, Dimes, Nickles and Pennies
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;
namespace VendingMachine
{
//GOAL: Calcualte the change needed in quarters, dimes, nickles and pennies.
class Program
{
static void Main(string[] args)
{
int totalChange, quarter, dime, nickle, penny;
totalChange = GetValue();
quarter = GetTheTotalAmountQ(totalChange);
dime = GetTheTotalAmountD(totalChange - 25* quarter);
nickle = GetTheTotalAmountN(totalChange - 10* dime);
penny = totalChange;
DisplayTotal(penny, quarter, dime, nickle);
Console.ReadLine();
}
static int GetValue()
{
string amount;
int coin;
Console.WriteLine("How much did you deposite?");
amount = Console.ReadLine();
coin = int.Parse(amount);
return (coin);
}
static int GetTheTotalAmountQ(int totalChange)
{
int quarters;
quarters = (totalChange / 25);
return quarters;
}
static int GetTheTotalAmountD(int totalChange)
{
int dimes;
dimes = (totalChange / 10);
return dimes;
}
static int GetTheTotalAmountN(int totalChange)
{
int nickles;
nickles = (totalChange / 5);
return nickles;
}
static void DisplayTotal(int quarter, int dime, int nickle, int penny)
{
Console.WriteLine("There are {0} quarters. \n", quarter);
Console.WriteLine("There are {0} dimes. \n", dime);
Console.WriteLine("There are {0} nickles. \n ", nickle);
Console.WriteLine("There are {0} pennies. \n", penny);
Console.Write("Thank you.");
}
}