The Mother Board forums. Free tech support, motherboard ID, and more.
It is currently Mon Dec 10, 2018 5:19 pm

All times are UTC - 8 hours

Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Oct 30, 2007 12:03 am 

Joined: Sat Jul 28, 2007 9:43 am
Posts: 14
In my entry-level computer science course, the professor wants us to write a little program that will classify a message as spam or not. Some of the instructions that are giving me trouble are the following:

1. "Enter the body of the email. Press enter on an empty line to finish." I don't understand how to do this. To make myself clear here, I mean that the user has to press Enter on an empty line in order to finish writing the body part. Example:
//This is what I want, but don't have.
Hi mom. <-- the user is able to hit the Enter key on this line
<-- and again on this line to submit the body.

//This is what I have, but don't want.
Hi mom. <-- the user is only able to press Enter once before the program takes the input.

2. What do I do to check if a string has least one word, and more than 90% of the words in the subject line consist of only uppercase letters?

More questions to come soon :x Thanks in advance.

Reply with quote  
 Post subject:
PostPosted: Sun Dec 02, 2007 4:08 am 
Black Belt
Black Belt

Joined: Sun Jun 29, 2003 3:58 pm
Posts: 615
Location: South Africa, Cape Town
this seems like a console application.
1.) try looking into the getline() function. then your can concatenate the results in the end.

2) the long way around would be to loop through the string character by character. Read the text into an array until you get to a 'space'. Afterwards check each array item for uppercase/lowercase (sorry cant remember string function names), and keep count of those that match the condition.

not sure how much detail you need. ask if you need any more help.

-dve83- Folding for 33258
Gigabyte GA-MA69VM-S2,AMD Athlon X2 5200+, 6GB DDR2-800, Seagate 250GB 7200 RPM, Western Digital 1TB 7200RPM,
460W Coolermaster PSU, Windows 7

"Perhaps it's not paranoia. Perhaps it's just finesse." - dve83

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group