Hi Everyone, I am taking C++ for the second time and I am understanding it better this time around. I have an assignment that needs a switch (got that, know how to do it), I have put if/else statements inside of the cases. The thing I can't get to work…
i guess your mistake is not using break; after each case... if you don't do this, your switch will run all the way until all the cases are done...
another thing i would advise you to do is use the default until the end of the switch statement, since this way you will not have this kind of problems...
this i wrote it as a response to your first post, where the program executed all of the commands even ehen they were in a switch...
you are pretty close to what is posting correctly your code... all you have to do identify the code you are using as c code ([[B]code=c[/B]]), and write your code with the right margins so it is easier to follow...
second, what your teacher means by putting the package in a loop is that, for example, if the user inputs the wrong package once, he will be able to input a wrong package the second time, and get away with murder... this is why you must do a while loop that checks if the user's answer is inside the boundaries of the package...
i recommend you do the same thing with the hours...
by the way... there's no need to do this:
case 'a':
case 'A':...
you can do it this way:
case ('a'||'A'):...
i'm sure narue will correct me if i'm wrong...
this, i wrote it as a response to your second question, answering what your teacher meant when he said that your package needed to be inside a loop...
but, it works with what lovetwins wants to do, since it will evaluate if package equals to 'a' or || 'A' ...
this and almost all that follows is an excelent explanation given by narue and WaltP about why
case 'a':
case 'A':...
is not the same thing as
case ('a'||'A')
besides... let me remember you that we are solving YOUR problems so i think we need a little respect here... we (specially those who have been here a long long time) might know better than you would about how to handle posts and threads... plus... who doesn't get a little off topic once in a while?
Nichito
Posting Virtuoso
1,717 posts since Mar 2007
Reputation Points: 424
Solved Threads: 73
Skill Endorsements: 3
>Seems to me, that this is more a a gossip forum, than a help forum.
I'd disagree, but that's unlikely to change your view. And quite frankly, if you're reacting like a child to something so trivial, I'm not interested in changing your view. You can whine, cry, stamp your feet, hold your breath, and leave Daniweb for all I care. You haven't made enough of an impact for us to even notice that you left.
>I came here for help and advice, not to waste my time reading all the
>bickering and snide comments you all had to say to each other. It was a waste of my time.
Wow, you're a real jerk. I'm sorry we wasted your time, and I guess we'll never be seeing your ungrateful presence around here again. That's a good thing too, because I'm sure you'll be a big baby every time you don't get exactly what you want in exactly the form you want. And I can guarantee that you'll encounter situations worse than a slightly off-topic thread with that attitude.
>I'm appauled that a so called moderator would even be pulled into discussions as such.
I'm constantly appalled that people seem to think that being a moderator means I'm not allowed to participate in regular threads. :icon_rolleyes: This is the single most annoying complaint I see when someone doesn't agree with my actions. "You're a moderator, how can you do that?" Are you guys really so stupid that you can't see the difference between enforcing the rules and being active in the community?
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,483
Solved Threads: 1,407
Skill Endorsements: 54
> Seems to me, that this is more a a gossip forum, than a help forum.
You are the only one with this kind of opinion I guess.
> I came here for help and advice.
If you still haven't been able to find those, then you are not cut for programming.
> It was a waste of my time.
You were in need of help. It was actually a waste of our time. This kind of attitude would get you nowhere.
> I would like to thank the ones that were actually trying to suggest ideas.
This kind of attitude would get you everywhere. This is the way it has to be when you ask for help.
You have to bear in mind that no one here is obliged to answer any questions. Its the desire to help beginners which drives us, replies like yours are a real turn off.
~s.o.s~
Failure as a human
12,220 posts since Jun 2006
Reputation Points: 3,307
Solved Threads: 783
Skill Endorsements: 55
>By the way, I solved the problem without the your so called solutions.
I'm glad you solved your problem. Now I can put on my moderator hat and lock this thread to keep you from starting a real flame war.
>I think that if there is any disrespecting going on it is from you.
The first person to show disrespect was you when you threw away everyone's help to bitch and moan about how we were wasting your time. You clearly aren't interested in being nice, so don't expect us to be nice in return.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,483
Solved Threads: 1,407
Skill Endorsements: 54