Can everyone help me?

Write a Java program called ass_sm2.java that repeatedly asks users to input a positive integer and then output the minimum number of coins needed to exchange the input amount. Your program should stop running when users entered 0 as the amount. In addition, if the number of coins required for a particular type(s) equals 0, do not show it in the output.
For simplicity, only ten-dollar coins, five-dollar coins, two-dollar coins and one-dollar coins needed to be considered.
To be more specific, your program should perform the following:
1.     Prompt the user to input an integer using showInputdialog.
2.     If the input does not equal to 0, calculate the minimum number of coins needed to exchange the input amount and stores them in some variables.
3.     Show the input amount and minimum number needed in separate lines using showMessagedialog.
4.     Prompt the user to input an integer using showInputdialog.
If the input does not equal to 0, repeat steps 2 to 4 again, else exit the program.
Tips:
�     You could make use of the / and % operators to calculate the required number of coins.
�     Use a while loop to check the exit condition.
�     Use a String variable to store the output contents from time to time.

OK!
I will give you some help!
This type of programming is called "Greedy". This means that you always take a greedy choice of the next, in this case coin, thing you'll pick.
Your available change is 10,5,2,1
Say that you for instance have 16 dollars. A greedy choice would be first taking a 10, this reduces the problem to 6 dollars. A new greedy choice is thus 5 dollars, and then 1 dollar, so you need 3 coins. There is no better way of picking coins than this so it is the optimal number of coins.
Now, you do the programming lazy ass!
You can also think about another more complicated situation, if you have the change 11,6,4,1 dollars as change!

Similar Messages

  • Hello... the airport (wifi) connection on my imac is oftenly "freeze" and need to reconnect again. Can everyone help to solve this problem? It's not happened to other computer on the same network in the same area (distance). Thanks a lot.

    Hello... the airport (wifi) connection on my imac is oftenly "freeze" and need to reconnect again. Can everyone help to solve this problem? It's not happened to other computer on the same network in the same area (distance). Thanks a lot.

    Hello,
    Make a New Location, Using network locations in Mac OS X ...
    http://support.apple.com/kb/HT2712
    10.5, 10.6, 10.7 & 10.8…
    System Preferences>Network, top of window>Locations>Edit Locations, little plus icon, give it a name.
    10.5.x/10.6.x/10.7.x/10.8.x instructions...
    System Preferences>Network, click on the little gear at the bottom next to the + & - icons, (unlock lock first if locked), choose Set Service Order.
    The interface that connects to the Internet should be dragged to the top of the list.
    If using Wifi/Airport...
    Instead of joining your Network from the list, click the WiFi icon at the top, and click join other network. Fill in everything as needed.
    For 10.5/10.6/10.7/10.8, System Preferences>Network, unlock the lock if need be, highlight the Interface you use to connect to Internet, click on the advanced button, click on the DNS tab, click on the little plus icon, then add these numbers...
    208.67.222.222
    208.67.220.220
    (There may be better or faster DNS numbers in your area, but these should be a good test).
    Click OK.
    If that doesn't work try changing channels on your Router.

  • TS3694 hey everyone.. i have a problem with my 3Gs iphone.. i updated to the ios5 and now when i open it says that i have to connect it with the itunes. when i connect it says that has an error 28 something like that.. can anyone help me to fix it?? Regar

    hey everyone.. i have a problem with my 3Gs iphone.. i updated to the ios5 and now when i open it says that i have to connect it with the itunes. when i connect it says that has an error 28 something like that.. can anyone help me to fix it?? Regards

    Error 23, 28, 29: These errors may indicate a hardware issue with your device. Follow the steps in this article. Also attempt to restore while connected with the white USB Dock Connector cable that shipped with your device, on a known good computer and network to isolate this issue to the device. The MAC address being missing or the IMEI being the default value, (00 499901 064000 0), can also confirm a hardware issue. Out-of-date or incorrectly configured security software can also cause these errors.

  • Hello everyone! I'm having a trouble... I need to download Adobe Illustrator for windows 8, but i'm not able for doing that. Can you help me Please?

    Hello everyone! I'm having a trouble... I need to download Adobe Illustrator for windows 8, but i'm not able for doing that. Can you help me Please?

    Downloadable installation files available:
    Suites and Programs:  CC 2014 | CC | CS6 | CS5.5 | CS5 | CS4, CS4 Web Standard | CS3
    Acrobat:  XI, X | 9,8 | 9 standard
    Premiere Elements:  13 | 12 | 11, 10 | 9, 8, 7 win | 8 mac | 7 mac
    Photoshop Elements:  13 |12 | 11, 10 | 9,8,7 win | 8 mac | 7 mac
    Lightroom:  5.7.1| 5 | 4 | 3
    Captivate:  8 | 7 | 6 | 5.5, 5 | 1
    Contribute:  CS5 | CS4, CS3 | 3,2
    FrameMaker:  12, 11, 10, 9, 8, 7.2
    Download and installation help for Adobe links
    Download and installation help for Prodesigntools links are listed on most linked pages.  They are critical; especially steps 1, 2 and 3.  If you click a link that does not have those steps listed, open a second window using the Lightroom 3 link to see those 'Important Instructions'.

  • I am trying to send an email to myself and BCC everyone in my address, but have forgotten how. Can someone help me with this?

    I am trying to send an email to myself and bcc everyone in my address book, but have forgotten how. Can anyone help me with this? Thanks.

    http://chrisramsden.vfast.co.uk/7_How_do_I_send_to_everyone.html

  • TS2771 hi everyone, can you help me, because my ipod touch 5th gen, is not opening since this morning, i am just listening to music last night. And its not working anymore. THANK YOU

    hi everyone, can you help me, because my ipod touch 5th gen, is not opening since this morning, i am just listening to music last night. And its not working anymore. THANK YOU

    If not successful try the ramaining items of
    - iOS: Not responding or does not turn on
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try on another computer
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar       

  • Sharing enabled with everyone, but they are not getting my recently purchased music. Can anyone help?

    Hi! I am the organizer of my apple "family". I have sharing enabled with everyone, but they are not getting my recently purchased music. Can anyone help?

    Hello alisannlh,
    Thank you for participating in the Apple Support Communities.
    If you have Family Sharing set up, but your family does not see shared purchases, make sure they're following the steps from this article to access your shared purchases:
    Sharing purchased content with Family Sharing - Apple Support
    If they follow the steps above and can't see or download your purchases, the troubleshooting steps in this article can help:
    If you don't see your family's shared content - Apple Support
    All the best,
    Jeremy

  • Hi everyone. I'm from Italy and I'll go to NY next month. I want to buy a new iPhone 5s in NY but I'm not sure if I can use it in Italy. Can anyone help me? Thanks a lot!!!

    Hi everyone. I'm from Italy and I'll go to NY next month. I want to buy a new iPhone 5s in NY but I'm not sure if I can use it in Italy. Can anyone help me? Thanks a lot!!!

    1. Don't do it and waste your money
    2. The US prices exclude Tax which is added at the till depending on state and can be upto 15% more than the quoted price. All EU retail prices are required to include local taxes and import duties by regulation.
    3. On return to the EU you are liable for 22% VAT on your purchase
    4. The iPhone does NOT have an international warranty.It breaks you are stuffed.
    5. The US models do NOT support all European LTE frequencies .None support the Band 7 (2600mhz) frequency being deployed by many European Mobile networks.
    6. Buy locally if you want all functionality warranty support and when taxes are included the prices are pretty much the same anyway.

  • I had my iphone 3gs unlocked so i could use it in Oz, however although i can phone works ok, i cant get internet, but i the option of Cellular Data Network does not appear with the new sim? Can anyone help pls?

    Hi Just wondered if anyone can help with the above question? I had O2 phone unlocked and bought a local sim card, but although the calls are fine i have no option for internet etc.  I have done searches and got the info details from the sim provider to activate, but  instructions say i go to : Settings; General; Network and then Celluar Data Network, but I dont get that option ?  When i put back my O2 sim card, the option reappears?
    Can anyone help me please? Off to Australia again soon and really could do with it working properly this time.
    Thanks everyone
    Ronnie

    Hi Ronnie, was wondering what brand sim card you bought?
    Was it from Telstra, Optus, Vodafone, Virgin or Mayasim?
    I have a 4 S running iOS 5.01 is there an option in Settings - Network - Carrier? As this should be set to the supplier of the sim card. In my Settings - Network there is no option for Celluar Data Network.
    What version of the iOS are you using?
    Some prepaid sim cards may not have a lot of data, so I suggest searching the companies websites for the best deals before you come here. Telstra usually have good plans. If you take your phone to the shop you purchased the sim card from they will usually set it up for you. 
    Telstra runs on a different frequency to others and offers the best coverage in Australia.
    Just for the record I am not an employee of any mobile company.

  • Hi All, I just installed PS CC 2014 and Deleted PS CS6.  I have a HUGE problem! The Liquify Filter on PS CC 2014 is not working.   When the filter comes up, my photo is reduced to two color fields - bright turquoise and lime green!  Can anyone help me?  I

    Hi Everyone,
    I just deleted PS CS6 and installed PS CC 2014. I'm trying to use the Liquify Filter and it does not work.  When I click on the Liquify Filter, my photo does not appear properly.  The photo appears as two flourescent color fields - bright turquoise and lime green!  Can anyone help me with this?  Also, does anyone know if I can re-install Photoshop CS6?
    Thanks!
    Laraine

    Hi Everyone....I figured it out.  Strangely, although I had NEVER used Liquify in PS CC 2014....I just realized that in Liquify Advanced Mode that the "SHOW MASK" option was on by default!  I unchecked SHOW MASK.  Everything is OK. Whew!  Tks!

  • When my 4S connects to my home wifi, it kicks all other devices off and the router has to be restarted.  Can anyone help?

    I am using an iPhone 4S with 16gb memory.  I did not yet update to iOS 8.  I'm using 7.1.2.  I have never had any problems previously using 3G or wifi.  We just moved and have a new Netgear router supplied by our new ISP.  We have ADSL connection.  The router seems to be working fine for all the devices in the house.  At any time we may have 2 or 3 laptops connected, as well as Kindle Fires, iPod Touches, and my husband's iPhone (which is the same make, model, year as mine).  My iPhone will connect, but usually within minutes after connecting my iPhone 4S (though sometimes 30 minutes or more later), it kicks everyone offline and the router needs to be restarted.  The router shows appropriate green lights and I can see it on my list of available networks, but if I try to connect I get the "unable to connect to this network" message until we restart the router.  No one else is able to reconnect until the restart, either.
    I have tried resetting network settings on my iPhone.  I have completely turned off my iPhone and the router.  I have talked with someone at our ISP and they did a reset of the router with me.  They think the router is bad.  But it works completely fine for everyone else in the house, so I can't help but think we are having a connection issue between the router and my iPhone.
    Any help you can offer would be greatly appreciated!  Thank you!

    Is her iPhone in a case by any chance?  If so, remove the case and try again.  How does her iPhone work in free Wi-Fi locations?
    Try resetting the iPhone...
    Press and hold the Home and On/Off buttons simultaneously until you see the Apple logo, then release.  This may take up to 10 seconds.  This is the equivalent of a re-boot and you will not lose any data.
    If none of the above work take it to an Apple store or AASP for evaluation.  She will not be charged folr this and they will suggest a solution if there is a fault.

  • PB suddenly crashes! Black screen. Wont turn back on. Can anyone HELP ???

    Hello everyone!
    My 16months old 12" PowerBook suddenly crashed last time when I was working with it. I didnt do anything particularly challenging. The PB didn't get extremely slow or anything. All of a sudden it just turned down within a second. and the display went black. By the way, it was not running on battery but over power cord.
    Then right away after crashing there was this weird high-pitched sound coming from the backside of the PB. When I tried to turn it back on the sound muted, still the PB wouldn't go back on.
    It felt as if it wast all the way shut down, and not really on either.
    I tried the key combination shiftoption+applepower button (or whatever it was) to restart it, but it didnt work.
    so I took off the power adapter cord, and took out the battery.
    After putting the battery back in i was able to turn the PB back on.
    All this happened 3 times now.
    very weird and very frightening!! Does anyone have a clue?? Can anyone help???
    PLEEEASE!!
    thanx.
    PowerBook G4   Mac OS X (10.4.4)   1.33 GHz, 512 MB, Mini-DVI

    That's not much to go on, but here are a couple of guesses that may lead you in the right direction:
    1) The high pitched noise could have been a fan dying, followed by the CPU overheating and the system shutting itself off to prevent damage. If you left it sitting for a couple of hours and it rebooted okay (or started to), and then crashed again shortly thereafter then it's probably a fan.
    2) If now the system sounds and feels like it's booting up normally, but with nothing on the screen at all, the lamp (not sure what the technical term is) for the LCD could have gone bad. This happened to me a while back. If you have an external monitor available, try plugging it in and see if the machine comes up on that display.
    Either way you're almost certainly going to want to take it in to be serviced. Best of luck!

  • Adobe Premiere Elements 10 has stopped working Windows 7 Error Message - Can someone help?

    Hello Everyone,
    I wanted to checkout the new version of Adboe Premiere Elements 10 for doing some film editing so I downloaded the Trial Version using the Adobe Download Manager.  Upon installation, I double-clicked the Elements icon and after a few seconds of trying to open, I get the following:
    After surfing the web, I followed several steps to ensure I had all of the latest drivers for audio/video components and the latest version of QuickTime.  I uninstalled and re-installed Elements 10 and ensured that my virus protection was turned off. 
    I am still getting the same error.
    Can anyone help?
    Thank you in advance!
    Will

    Will,
    Welcome to the forum.
    This ARTICLE has a checklist on getting PrE to work well on one's computer, and then it goes into tuning the computer and OS. Last, there are linked articles on troubleshooting, and on many aspects of one's computer and OS, when the general tune up tips do not fix things. If the checklist, and tuneup tips do not help, then step through the troubleshooting tips, one at a time, as they work up in "degree of difficulty."
    Good luck,
    Hunt

  • Can anyone help with a simple coding problem?

    I'm creating a website using Dreamweaver MX 2004 and making a
    real mess of it!
    I have created two pages which are identical in terms of
    background, but one has a text box in the middle. What I want to
    happen when you click the link to this page is the first one
    without the text box appears for a couple of seconds, then the
    other page automatically loads to give the impression that this
    text box has magically appeared. really simple, but I can't find
    any behaviour codes to make this happen!
    Can anyone help me out with a code or give me a clue to how
    it can be achieved really easily.
    Cheers everyone!

    You can try just using the same page and hiding and showing
    the layer using the Behaviors menu. that would acheive the same
    thing without having to load another page.

  • I cannot update from OS 10.9.4 to 10.9.5. I get a message saying: File couldn't be installed error (513). I have configured my OS so that I have read and write permission followed by system with read and writ permission. Can someone help me? Thanks.

    I cannot update from OS X 10.9.4 t0 10.9.5> Whenever I try I get the following message: File couldn't be installed error (513) and something about not having the proper permission.  Under the Macintosh HD sharing and permissions settings I have customized the settings so that (Me) has read and write permission followed by the system with read and write permission, wheel and everyone have Read permissions.
    I have no problems updating apps such as Adobe CC or iTunes but cannot update the operating system, can someone help me? Thanks.

    1. Restart the computer in safe mode. Certain caches maintained by the system will be rebuilt.
    Safe mode is much slower to start up than normal. The next normal startup may also be somewhat slow.
    When the login screen appears, restart as usual (not in safe mode) and test. There's no need to log in while in safe mode.
    Note: If FileVault is enabled, or if a firmware password is set, or if the startup volume is a software RAID, you can’t start in safe mode. In that case, go to Step 2.
    If there's no change after taking this step, continue.
    2. Back up all data before proceeding.
    Triple-click anywhere in the line below on this page to select it:
    /var/folders
    Right-click or control-click the highlighted line and select
              Services ▹ Reveal in Finder (or just Reveal)
    from the contextual menu.* A folder should open with an item named "folders" selected. Move the selected item to the Trash. You may be prompted for your administrator login password. Restart the computer and empty the Trash.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination  command-C. In the Finder, select
              Go ▹ Go to Folder...
    from the menu bar and paste into the box that opens by pressing command-V. You won't see what you pasted because a line break is included. Press return.

Maybe you are looking for