Results 1 to 3 of 3

Thread: Change calculation (console app)

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2016
    Posts
    11

    Question 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!

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    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

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Change calculation (console app)

    Quote Originally Posted by Moyase View Post
    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...

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
  •  



Click Here to Expand Forum to Full Width