>> I agree, this is a new stragety for homework.
Anyone else remember the people posting their homework questions in the Contests Board? It's so genius that if I were a mod I'd've overlooked it
>> I agree, this is a new stragety for homework.
Anyone else remember the people posting their homework questions in the Contests Board? It's so genius that if I were a mod I'd've overlooked it
Hi Guys,
You have made me very disappointed. i was not here for my homework, just here to help someone. i have made many efforts in writing that code, but failed, you can see my attempts ... i again said Not everyone here for home work, there may be some other purpose...
Code:#include <iostream.h> void main(){ char value; int c,num,sum; int total,aces,done; cout << "How many cards do you have? (2-5)"; cin >>total; c=1; sum=0; aces=0; while (c<=total){ cout<<"Input value of card #"<<c<<" (2-9 or j,q,k,a)"; cin>>value; if (value=='2'){ num=2; } elseif (value=='3'){ num=3; } elseif (value=='4'){ num=4; } elseif (value=='5'){ num=5; } elseif (value=='6'){ num=6; } elseif (value=='7'){ num=7; } elseif (value=='8'){ num=8; } elseif (value=='9'){ num=9; } elseif (value=='t'){ num=10; } elseif (value=='j' || value=='q' || value=='k'){ num=10; } elseif (value=='a'){ num=11; aces++; } sum=sum+num; c++; } if (sum>21){ if (aces>0){ c=0; done=0; while (done!=1){ sum=sum-10; aces=aces-1; if (aces==0 || sum<=21){ done=1; } } } } If (sum>21){ cout << "Busted"; } else{ cout <<sum; } }
i.e., here to help someone else get his/her homework done? Either way the homework policy applies, and you have pretty much attempted to mislead the community here by making it seem like a friendly "challenge" (which should be in the contests forum anyway, as noted by twomers ).i was not here for my homework, just here to help someone.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
now can you help me, what i have done wrong in that program ??
I shall be nice this time round:now can you help me, what i have done wrong in that program ??
1. You used <iostream.h> instead of the standard <iostream> header.
2. You used void main() instead of the standard int main().
3. You used If instead of if (C++ is case sensitive for keywords).
You could simplify the handling of your card input by checking for ranges, but that should affect whether the code compiles or not. Note that I have not checked your logic.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
That long if-elseif statement could be replaced with a switch statement, but that's just a suggestion. BTW, "elseif" is two words, "else if".
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Also "elseif" should be two words, as in "else if"
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Oops, the dangers of alternating between C++ and PHP message boardsAlso "elseif" should be two words, as in "else if"
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
You'd also need an argument as to whether or not an ace is a '1' or an '11'. Something like;
Code:else if (value=='a'){ if(sum>11) { num=1; aces++; } else{ num=11; aces++; } sum=sum+num; c++; }
Well, his six hour deadline that he told us about has already passed.
What are the Vegas odds he passed/failed the assigment?
Personally, it's not in my nature to be mean-spirited, but some of you Guys n' Dolls have been around a long time, so I imagine that wears on your patience. No doubt, you've seen it all. If the person posted the code first off though, he would have received plenty of help and his task would have been completed in no time.
I certainly understand members sayin', show you code, then we'll help.
Yup, that's the policy, even if it was homework if he posted a good effort and really tried, we could help him out, hell, half the stuff i've learned i've learned from here. No book in the world compares to this community. But when someone just posts something that is called a "Contest" without code then to us it sounds like "Homework"
Like i said, if he/she did it right the first time we never would've gotten into this =P
haha
"Anyone can aspire to greatness if they try hard enough."
- Me
@ Wraithan, that dictionary says it is Slang in all its usages and all of the sources are cited as being American, I count that as an American word not a proper English word.
The whole point of being set work is that they learn from attempting to do it (as opposed to passively just listening to or reading rules).
Kinda how most decent programmers learn
We had a guy at our place recently (now fired) who would say to me "what can I do at home to improve my ability?"
lol?
I told him to go home and write programs to do stuff.................
This guy had a 1st in CS.
we are one