PDA

View Full Version : assignment 6


kks7696
06-17-2016, 02:42 PM
It was very tricky first I could not figure out how to make it count down, I just had the while statement in there finally I added a if else statement and was able to get it to count down until it got to 2. Finally I added an if statement that said if it equaled one to set the value to a string that said 1. Then I struggled with getting it to say bottle and not bottles at the end, but I was able to combine the if and else statements above and on the else statement join it with the word bottles and remove the word bottles from the song, add bottle to the if statement and perfecto. I still could not get rid of the decimal place and it shows 99.0, 98.0 and so on but I am not sure if you even can get rid of it, so I uploaded it. Hopefully the teacher is impressed it took me a few hours to complete.

willy0227
07-19-2016, 12:12 AM
I like your use of if statements to accomplish this, but there is a simpler way to do this. I used a while statement that ran as long as my variable was <= 99 AND > 1. Then I ran the statements with my variable for the first 2 lines. Then decremented my variable by 1, and ran the final line. This ran the loop over and over until it equals 1. Then outside the loop I put the same statements changing bottles to bottle and it finished. I will say it frustrated me that I couldn't do this with a loop and decrement the index instead of increment. Even if I could, it would not let me do any math on the index while it was in the "as a string" function. This is how I would have done it in the other languages I know.