Alice Community  

Go Back   Alice Community > General Discussion > Questions and Comments

Reply
 
Thread Tools Display Modes
assignment 6
Old
kks7696
Junior Member
 
Status: Offline
Posts: 7
Join Date: Jun 2016
Default assignment 6 - 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.
   
Reply With Quote
Old
willy0227
Junior Member
 
Status: Offline
Posts: 8
Join Date: Jul 2016
Default 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.
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2017, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.