Change calculation (console app)
Alright, so I need to write a console application that when given a value (cents) UNDER A DOLLAR, will tell you what you need to pay in:
Quarters:
Dimes:
Nickles:
Pennies:
Example - Change = 69 cents
Q = 5
D = 1
N = 1
P = 4
If some one could just point me in the right direction that'd be great! Here is my code so far
\
Code:
Sub Main()
Dim iChange, iQuart, iDime, iNick, iPen, iChangeQ, iChangeD, iChangeN, iChangeP As Integer
Console.Write("Enter the amount of change in cents: ") 'Input
iChange = Console.ReadLine()
iChangeQ =
iQuart = iChange \ 25
iDime = iChange \ 10
iNick = iChange \ 5
iPen = iChange \ 1
Console.WriteLine("Quarter(s): " & iQuart)
Console.WriteLine("Dime(s): " & iDime)
Console.WriteLine("Nickle(s): " & iNick)
Console.WriteLine("Pennie(s): " & iPen)
Console.ReadLine()
End Sub
Thanks in advance! :)
Re: Change calculation (console app)
Code:
iQuart = iChange \ 25
iChange -= CInt(iQuart * 25)
iDime = iChange \ 10
iChange -= CInt(iDime * 10)
iNick = iChange \ 5
iChange -= CInt(iNick * 5)
iPen = iChange
Re: Change calculation (console app)
Quote:
Originally Posted by
Moyase
Alright, so I need to write a console application that when given a value (cents) UNDER A DOLLAR, will tell you what you need to pay in:
Quarters:
Dimes:
Nickles:
Pennies:
Example - Change = 69 cents
Q = 5??? $1.25
D = 1
N = 1
P = 4
'=$1.44.:D
If some one could just point me in the right direction that'd be great! Here is my code so far
\
Code:
Sub Main()
Dim iChange, iQuart, iDime, iNick, iPen, iChangeQ, iChangeD, iChangeN, iChangeP As Integer
Console.Write("Enter the amount of change in cents: ") 'Input
iChange = Console.ReadLine()
iChangeQ =
iQuart = iChange \ 25
iDime = iChange \ 10
iNick = iChange \ 5
iPen = iChange \ 1
Console.WriteLine("Quarter(s): " & iQuart)
Console.WriteLine("Dime(s): " & iDime)
Console.WriteLine("Nickle(s): " & iNick)
Console.WriteLine("Pennie(s): " & iPen)
Console.ReadLine()
End Sub
Thanks in advance! :)
glad it's working for you...