Dmitri Makovetskiy wrote:
i want to convert all those while loops to for. this would allow me to use if and else.
You can use if-else statements with while loops, too.
Dmitri Makovetskiy wrote:
i must have if and else's.
Why? If you're thinking goes "I MUST use THIS data structure" or "I MUST use THAT control structure", you're not approaching the problem right. You're saying "I HAVE to use a hammer, even thought I want to drill a hole".
You should be saying "I need to drill a hole, so the best tool would be a drill".
Dmitri Makovetskiy wrote:
The structure should be like that.
if
the letter appears in the string
print it
if it doesnt
ask for another number.
Are you saying you want to verify the user input, character by character?
Dmitri Makovetskiy wrote:
so far the code isnt working and tells me there is a mistake
I"m not surprised. You seem to be simply firing random chunks of code at us, saying "This doesn't work". You need to stop and back up. What EXACTLY are you trying to do? I
think you want to do this:
Ask the user to input a hex. number
While the number is not valid hex, ask them to try again
once they have input a valid hex number, print the decimal equivalent.
Is that correct?
Dmitri Makovetskiy wrote:to tell you the truth. i dont think my code will recognize 2000 as a value... i think i need to redesign the whole thing, with different loops. what do you think?
I honestly can't even look at your code anymore, because it's not clear what you're trying to do. The best way to approach this is to write out step by step what should happen. Keep refining it until it's crystal clear to everyone what should occur. then start coding it in as little pieces as possible, and
testing it as often as possible. Only when you're sure what you just wrote works flawlessly should you try and do the next step.