943,645 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 534
  • C++ RSS
Nov 30th, 2008
0

C++ problem

Expand Post »
can someone help me to slove this using c++ please.
Attached Thumbnails
Click image for larger version

Name:	task.png
Views:	18
Size:	39.0 KB
ID:	8410  
Last edited by chchiu; Nov 30th, 2008 at 10:08 am.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
chchiu is offline Offline
6 posts
since Nov 2008
Nov 30th, 2008
0

Re: C++ problem

Noone will spoonfeed you any solutions. have a good attempt at the problem for yourself and come back if you get stuck on anything along with a description of whatever it is you need help with, and the code you've tried so far.
Reputation Points: 307
Solved Threads: 62
Posting Pro
Bench is offline Offline
565 posts
since Feb 2006
Nov 30th, 2008
0

Re: C++ problem

How should i begin??
Reputation Points: 10
Solved Threads: 0
Newbie Poster
chchiu is offline Offline
6 posts
since Nov 2008
Nov 30th, 2008
0

Re: C++ problem

There are a couple approaches in c++ language:

1) if input is in the form of a std::string object, you can use it's find() method to determine if it contains any of the words, example:
C++ Syntax (Toggle Plain Text)
  1. std::string input;
  2. cout << "Enter a word\n";
  3. cin >> input;
  4. if( input.find("ONE") != std::npos)
  5. {
  6. // found it.
  7. }

2) The other way, using standard C style character arrays
C++ Syntax (Toggle Plain Text)
  1. char input[20];
  2. cout << "Enter word\n";
  3. cin >> input;
  4. if( strstr(input,"ONE") != NULL)
  5. {
  6. // found it
  7. }

Now if course you will have to change the above to check each of the words listed in your assignment, as well as all the other requirements which I did not mention.

And don't forget to include the appropriage header files.
Last edited by Ancient Dragon; Nov 30th, 2008 at 12:36 pm.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,947 posts
since Aug 2005
Nov 30th, 2008
0

Re: C++ problem

I really don't know how to code it....could you help me...Please x10000. I have to hand it in soon. I will remember you forever! Please help me!
Last edited by chchiu; Nov 30th, 2008 at 1:52 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
chchiu is offline Offline
6 posts
since Nov 2008
Nov 30th, 2008
1

Re: C++ problem

Quote ...
I will remember you forever!
Seriously, how much do you think we care? Moreover, I hardly think so. I'm pretty sure that you won't hold gratitude or appreciation soon after you'll hand that assignment. Not that I'd pay a penny for you being eternally grateful to me.

Ancient Dragon already gave you a start. I'm feeling to give you just some general advices:

1 - Divide your program in steps - most common are input, processing and output but you can elaborate this further
2 - Write one step at a time, for example begin with a program that only accepts one string input and quits. Then try to solve the problem for simplest cases (i.e. the user enters "one" or "nine").
3 - Post your code. We will gladly help you (not for the glory, however) if you show us you do care enough. When I ask for help I think that the time of people more expert than me is more precious than mine. Consequently, I have to devote more time than they do in solving my problem. If I don't act this way, I won't learn anything. Try to think this way and you'll be surely helped.

Regards
Reputation Points: 134
Solved Threads: 18
Junior Poster
mrboolf is offline Offline
182 posts
since Jun 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: How do you block certian inputs.
Next Thread in C++ Forum Timeline: What is The Difference Between CSocket() and socket()? Questions About MFC Wrappers





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC