|
-
Feb 17th, 2016, 11:58 PM
#1
Thread Starter
New Member
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!
-
Feb 18th, 2016, 05:45 AM
#2
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
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Feb 19th, 2016, 03:31 AM
#3
Re: Change calculation (console app)
 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.
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...
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|