![]() |
|
[Java] Comp Sci Help [LOOPS] - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Java] Comp Sci Help [LOOPS] (/showthread.php?tid=6024212) |
Comp Sci Help [LOOPS] - Yukino - Nov 11, 2019 Determine all possible ways to make change for a dollar using only quarters, dimes, nickels and pennies. The output must show the results, one line at a time, without showing zeros. Count the number of ways that the program finds to make change and print this result at the end of the program. For example: 2 quarters, 5 dimes NOT 2 quarters, 5 dimes, 0 nickels, 0 pennies. Honestly. I'm done with java. RE: Comp Sci Help [LOOPS] - Varius - Nov 12, 2019 You want a solved solution or a hint? make a counter for each type make a balance variable Try to put the balance divided by the counter size (i.e balance = 90 cents, quarter size is 25, so quarter_Counter = balance / quarter_size) then remove the size * counter from the balance and keep going down till you reach the smallest value. Then just do an if statement for each of the counters. RE: Comp Sci Help [LOOPS] - Yukino - Nov 12, 2019 (Nov 12, 2019 04:57 AM)Varius Wrote: You want a solved solution or a hint? Could you perhaps explain it using 4 for loops? RE: Comp Sci Help [LOOPS] - Accord - Nov 12, 2019 I like to help but dont get the question, still not good in English. I dont get quarter, dimes, pennies and nickels. RE: Comp Sci Help [LOOPS] - GenericSkid - Nov 12, 2019 (Nov 12, 2019 07:42 AM)Dionysus. Wrote: I dont get quarter, dimes, pennies and nickels. The question: How many ways can you count to 100 using only 25, 10, 5, 1. Examples:
RE: Comp Sci Help [LOOPS] - Eternal Darkness - Nov 12, 2019 (Nov 12, 2019 07:20 AM)Yukino Wrote: Could you perhaps explain it using 4 for loops? Using 4 loops: Code public static int breakCentsDown(int num) {RE: Comp Sci Help [LOOPS] - Accord - Nov 12, 2019 (Nov 12, 2019 12:17 PM)GenericSkid Wrote: The question: How many ways can you count to 100 using only 25, 10, 5, 1. Oh am very thankful, I dont really know the value of them and now I get it. |