0% found this document useful (0 votes)
23 views

Using Using Using Using Using Namespace: //GOAL: Calcualte The Change Needed in Quarters, Dimes, Nickles and Pennies

The document contains code for a vending machine program that calculates change owed in quarters, dimes, nickels and pennies. The program prompts the user to enter an amount deposited, calculates the number of each coin value needed for change using division, and displays the results. It contains methods to get the deposited amount from the user, calculate coin quantities for quarters, dimes and nickels, and display the total change breakdown.

Uploaded by

PatrickFagan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Using Using Using Using Using Namespace: //GOAL: Calcualte The Change Needed in Quarters, Dimes, Nickles and Pennies

The document contains code for a vending machine program that calculates change owed in quarters, dimes, nickels and pennies. The program prompts the user to enter an amount deposited, calculates the number of each coin value needed for change using division, and displays the results. It contains methods to get the deposited amount from the user, calculate coin quantities for quarters, dimes and nickels, and display the total change breakdown.

Uploaded by

PatrickFagan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

using

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.");

}
}

You might also like