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:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* 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
Go Back   Tech Support Forum > The IT Pro > Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Programming A discussion forum for programs and programming used in tech-related businesses.

Reply
 
LinkBack Thread Tools
Old 10-07-2008, 10:27 PM   #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
Attached Files
File Type: txt Lab5.txt (699 Bytes, 3 views)
EngagewithRage is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
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

Old 10-08-2008, 07:44 AM   #2 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
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--;
}
Does the program run correctly? (if the code above was right to start with it would go into an infite loop).

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?
}
Anyway, that's my input, the logic behind your origional program was perfect, and i believe it's the most efficient way of doing it too.

Cheers,
Jamey
__________________

Myspace
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-08-2008, 02:51 PM   #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
EngagewithRage is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-08-2008, 02:54 PM   #4 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
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;
Cheers,
Jamey
__________________

Myspace
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-08-2008, 03:02 PM   #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
EngagewithRage is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-08-2008, 04:30 PM   #6 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,880
OS: Vista, various linux distros


Re: a little help would be appreciated

Thats fine, glad to help.

Cheers,
Jamey
__________________

Myspace
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 12:03 AM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85