Click here to Skip to main content
15,896,473 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Consider the following example:

The user is invited to enter a small number and a large number, a skip number, and a target number. The small number will be incremented by one, and the large number will be decremented by 2. The decrement will be skipped each time the small number is a multiple of the skip. The game ends if small becomes larger than large. If the large number reaches the target exactly, a statement is printed and the game stops.

The user’s goal is to put in a target number for the large number that will stop the game.

What I have tried:

honestly, I can't wrap my head around the question, would really be great if someone could help out quickly. thanks.
Posted
Updated 16-Nov-21 9:51am
Comments
jeron1 16-Nov-21 13:44pm    
Try breaking the task into smaller pieces.
0. Input 4 numbers
1. Setup a loop (like a while() loop) in which you perform additions or subtractions on some of those numbers based on certain criteria (think if() statements).
2. When certain conditions occur, print the result, and exit the loop

Try completing this task on paper, using pseudocode, or a flow chart. Then try coding it, if at that point you have specific questions, then ask it here and post your code.

While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
 
Share this answer
 
Quote:
honestly, I can't wrap my head around the question

We can't teach you how to understand requirements as the skill comes with practice.
Just a few advices:
- Play the game by hand with a sheet of paper and a pencil, the more you play, the better will be your understanding, and the easier it will be to translate to algorithm/program.
- Learn one or more analyze methods, E.W. Djikstra/N. Wirth Stepwize Refinement/top-Down method is a good start.
Structured Programming.pdf[^]
https://en.wikipedia.org/wiki/Top-down_and_bottom-up_design[^]
https://en.wikipedia.org/wiki/Structured_programming[^]
https://en.wikipedia.org/wiki/Edsger_W._Dijkstra[^]
https://www.cs.utexas.edu/users/EWD/ewd03xx/EWD316.PDF[^]
Program Development by Stepwise Refinement[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900