![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Programming A discussion forum for programs and programming used in tech-related businesses. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Oct 2008
Posts: 18
OS: windows xp home edition
|
a little help would be appreciated
This is the lab i have to do, i got a basic program going but i dont think ive written it the way im suppost to, this is my intro to programming so a little help would be appreciated.
Lab Instructions: You have been tasked with creating a program that will create the lyrics to that famous road trip song “99 bottles of beer on the wall”. That way will on the trip if anyone forgets the words they can refer to the song sheet. Write a program that will accept the number of rounds to sing (for testing purposes) and then display the words to the song. If the entry is 10 start the lyrics at 10 Since each line of the song is too long to write on one line it needs to be broken down. You also realize that with all the verses the lyrics will be difficult to read and so you decide to skip a line after every two lines. 10 bottle of beer on the wall 10 bottles of beer take one down and pass it around 10 bottles of beer on the wall 9 bottle of beer on the wall 9 bottles of beer take one down and pass it around 9 bottles of beer on the wall 8 bottle of beer on the wall 8 bottles of beer take one down and pass it around 8 bottles of beer on the wall 7 bottle of beer on the wall 7 bottles of beer take one down and pass it around 7 bottles of beer on the wall All the way down to 1 bottle of beer The last line of the song will be "No more bottles of beer on the wall" Hint: To skip lines at every other lyric consider using a variable that goes from 0 to 1 then back to 0 to determine if a blank line should be written. Final product will contain: * 6 Step Process Sheet with the above collected data from above. * The C++ source that solves the problem Grading: Your grade will be based upon the following: * You were able to follow the instructions above and complete the task. * You found read and followed the instructions for emailing me ! * The lab was emailed to me before the due date. This is what i have so far |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) |
|
Design Team Member
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,880
OS: Vista, various linux distros
|
Re: a little help would be appreciated
Hey, your program seems fine... theres a few things i notice, where do you decrement the variable bottles in the while loop(i've added it in the code below)?:
Code:
while ( bottles > 0)
{
cout << bottles << " bottle(s) of beer on the wall," << endl;
cout << bottles << " bottle(s) of beer." << endl;
cout << "Take one down, pass it around," << endl;
cout << bottles << " bottle(s) of beer on the wall." << endl;
bottles--;
}
You could also stop the while loop at 1 and change the code after to output "1 bottle..." rather than having "bottle(s)"... Something like: Code:
while ( bottles > 1)
{
cout << bottles << " bottles of beer on the wall," << endl;
cout << bottles << " bottles of beer." << endl;
cout << "Take one down, pass it around," << endl;
cout << bottles << " bottles of beer on the wall." << endl;
//please remove this line if its wrong:
bottles--;
}
//by now as long as the variable was set as a positive number
//(you may also want to check for that)
//you know that you have to output one and zero...
if(bottles>0){
cout << "1 bottle of beer on the wall," << endl;
cout << "1 bottle of beer." << endl;
cout << "Take one down, pass it around," << endl;
cout << "1 bottle of beer on the wall." << endl;
cout << "No more bottlles of beer on the wall. "<< endl;
} else {
//there were no bottles to start with or a negative number?
}
Cheers, Jamey |
|
|
|
|
|
#3 (permalink) |
|
Registered User
Join Date: Oct 2008
Posts: 18
OS: windows xp home edition
|
Re: a little help would be appreciated
thanks man, i forgot about the (bottles--;) part of code, ive got a few corrections to make your input helps me out alot, at leat i know im going in the right direction. Yeah the program runs man but i gotta change up a few things to clean it up. Another thing i wanna ask is, the fact that i gota insert a blank line at the end of each verse
for example output (n) bottles of beer on the wall (n) bottles of beer take one down pass it around (n) bottles of beer on the wall (space) . . .and so on how would i go about doing that, my professor is being a dick about sharing that info>:D |
|
|
|
|
|
#4 (permalink) |
|
Design Team Member
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,880
OS: Vista, various linux distros
|
Re: a little help would be appreciated
glad to have helped, as for the space i think if you just add another endline character to the end of the last line it should work:
Code:
cout << "No more bottlles of beer on the wall. "<< endl << endl; //or just add another empty line to the bottom //cout << " " << endl; Jamey |
|
|
|
|
|
#5 (permalink) |
|
Registered User
Join Date: Oct 2008
Posts: 18
OS: windows xp home edition
|
Re: a little help would be appreciated
ahhh your quick, used your tips and the program runs fine, ill try adding another endline and see if it does the trick, thanks man, this puts me ahead a few weeks in my programming class, this will give me more time to focus on my other classes. thanks a lot man u rock
|
|
|
|
![]() |
| Thread Tools | |
|
|