The program I'm trying to create is one where it asks for an amount of money, lets say 10 bucks. It will take the input and then randomly come up with an amount of change that equals the input. So for example if you were to enter 10 bucks it might come out with 1,000 pennies and if you were to in put that again it might come back with 100 dimes or a combination of change.

The problem I'm having is getting the amount of change to equal the input. I can get it to randomly come up with different amounts of change the problem is that it just doesn't the equal input. I should mention this is all done under one function, or the main function.

8 Years
Discussion Span
Last Post by lyndon enero

Here I'll give another example of what I'm trying to do.

Lets say you input a number and it creates an equation for that number so lets say you enter the number 9
It would create the equation through randomly going through the operators and numbers and print the equation 3^2*1

Or lets say the input was 7 it would print out the equation 3*2+1.

The problem I'm having is that the equation it prints does not match the number that was input. In my program it is able to create an equation randomly but it doesn't create the equation that is equal to the input. So what I'm asking for in this example is how would I be able to get it so that it knows to create an equation that would equal the number that was inputted?

I've been trying for statements but so far no success. I've also been trying while loops too.

Edited by Noliving: n/a


So you want to go through
a op b op c
until the result matches your target.
Where a, b, c are integers and op are the various operators.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.