PLEASE HELP! very difficult Homework

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2009
Posts: 3
Reputation: Muathelbou is an unknown quantity at this point 
Solved Threads: 0
Muathelbou Muathelbou is offline Offline
Newbie Poster

PLEASE HELP! very difficult Homework

 
0
  #1
27 Days Ago
Anyone who can help me please do I am totaly lost. this is the homework:
You will implement a set of functions that will analyze and/or manipulate character data.

You are provided with a header file called charRoutines.h
that contains the declaratins (prototypes) for the
functions that you are to implement. You are to implement
these functions in a .cpp file called charRoutines.cpp:

#ifndef charRoutings_H
#define charRoutings_H

extern bool isUppercase( char c );
extern bool isLowercase( char c );
extern bool isAlphabetic( char c );
extern bool isNumeric( char c );
extern bool isAlphanumeric( char c );
extern bool isVowel( char c );
extern bool isSpace( char c );
extern char toUpper( char c );
extern char toLower( char c );
extern int toNumber( char c );
#endif

*** NOTE: you are not to modify the contents of the
charRoutines.h file for this assignment.
The following is an explanation of what each of the
routines should do:
bool isUppercase( char c )
Returns true if the character passed in is any uppercase
letter. If it is any other character, false is returned.
bool isLowercase( char c )
Returns true if the character passed in is any lowercase
letter. If it is any other character, false is returned.
bool isAlphabetic( char c )
Returns true if the character passed in is any uppercase
letter or any lowercase letter. If it is any other
character, false is returned.
bool isNumeric( char c )
Returns true if the character passed in is any
numeric digit. If it is any other character,
false is returned.
bool isAlphanumeric( char c )
Returns true if the character passed in is any uppercase
letter, any lowercase letter, or any numeric digit. If
it is any other character, false is returned.
bool isVowel( char c )
Returns true if the character passed in an uppercase
or lowercase vowel (a, e, i, o, u). If it is any other
character, false is returned.
bool isSpace( char c )
Returns true if the character passed in a space. If it is
any other character, false is returned.
char toUpper( char c )
If the character passed in is a lowercase letter, then
this function returns the uppercase version of that
letter. Otherwise, the parameter passed in is returned.
char toLower( char c )
If the character passed in is an uppercase letter, then
this function returns the lowercase version of that
letter. Otherwise, the parameter passed in is returned.
int toNumber( char c )
If the character passed in is a numeric digit, then the
integer value (not the ASCII code) of that digit is returned.
If the character is not a digit, -1 should be returned.

Restrictions
------------
- You are not allowed to include header files other
than charRoutines.h in your charRouters.cpp file.
Therefore, you can not use any ANSI C/C++ routines
to assist in your implementation of the functions.

- There are to be no hard-coded numbers in this
assignment. Use character literals when ASCII codes
are needed.

- The charRoutines.cpp file should only contain the
implementation of the above routines. Do not put
a main() routine in your charRoutines.cpp.

things needed in this homework:
- Proper use of multiple source code files.

- Proper use of character literals. No hard-coded
numbers for characters.
the goal of the HW:

- how to work with character literals without having to
put specific hard-coded ASCII values in your code.

- how to work with multiple .cpp source code files.

- how to think about testing what you implement.
Please help! I am totaly lost.
Thank you
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,728
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 737
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess
 
2
  #2
27 Days Ago
That's not what I would call "very difficult". You're also not likely to get any help by posting a homework assignment with no proof of effort. Show us that you tried to solve the problem first.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 139
Reputation: Frederick2 has a spectacular aura about Frederick2 has a spectacular aura about Frederick2 has a spectacular aura about 
Solved Threads: 14
Frederick2 Frederick2 is offline Offline
Junior Poster
 
0
  #3
27 Days Ago
Sometimes when you look at a whole long list like that it seems overwhelming. But instead of being overwhelmed by looking at the whole list, why not start with one very small piece at a time. The first function is this...

extern bool isUppercase( char c );

To write the function all you need to know are the ASCIIZ codes. You've certainly seen them before. Some are lower case and others are uppercase. That ought to suggest a starting point to you.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 3
Reputation: Muathelbou is an unknown quantity at this point 
Solved Threads: 0
Muathelbou Muathelbou is offline Offline
Newbie Poster
 
0
  #4
26 Days Ago
Originally Posted by Narue View Post
That's not what I would call "very difficult". You're also not likely to get any help by posting a homework assignment with no proof of effort. Show us that you tried to solve the problem first.
Thank you for the replay; Well for a "preschool" begginer in C++like myslef is like proving the theory of relativity which I absolutely have no clue. I would say the first few homeworks were kind of easy, you know the basic ones, hello world, the sum and average, the age...etc those kinds were easy then I missed 3 weeks of class for sickness and I never caught up with the class;not to mention that lab class never attended it falls on my work day. So I'm glad you saying not difficult if you can guide me at least how to start writting it I would be very thankfull.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 3
Reputation: Muathelbou is an unknown quantity at this point 
Solved Threads: 0
Muathelbou Muathelbou is offline Offline
Newbie Poster
 
0
  #5
26 Days Ago
Originally Posted by Frederick2 View Post
Sometimes when you look at a whole long list like that it seems overwhelming. But instead of being overwhelmed by looking at the whole list, why not start with one very small piece at a time. The first function is this...

extern bool isUppercase( char c );

To write the function all you need to know are the ASCIIZ codes. You've certainly seen them before. Some are lower case and others are uppercase. That ought to suggest a starting point to you.
Thank you for the advice; it is overwhelming truly, because I missed 3 weeks of the class and never caughtup. I am not fmiliar with the ASCIIZ codes yet, could you elaborate more on how to write that function please? thank you
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1,261
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 157
firstPerson's Avatar
firstPerson firstPerson is online now Online
Nearly a Posting Virtuoso
 
-1
  #6
26 Days Ago
Ascii Table

They represent the value of a character. For example :

All character from 'a' to 'z is represented by the decimal value 97 to 122.

So a function that would check if a character is a lower case character might look something like this :
  1. bool isLowerCase(char ch){
  2. //check if the ascii value of ch is between 97 and 122
  3. return ( ch >= 97 && ch <= 122 )
  4. }
1) What word becomes shorter if you add a letter to it? [ Solved by : niek_e, Paul Thompson]
2) What does this sequence  equal to :  (.5u - .5a)(.5u-.5b)(.5u-.5c) ...[*]
      [*solved by : murtan]
3) What is the 123456789 prime numer?
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 55
Reputation: BeyondTheEye is an unknown quantity at this point 
Solved Threads: 10
BeyondTheEye BeyondTheEye is offline Offline
Junior Poster in Training
 
2
  #7
26 Days Ago
FirstPerson's code works, but it's bad coding practice to hard code the ASCII numbers. Also stated in your assignment, if you are to use character literals you just have to change the numbers to letters.

  1. bool isLowerCase(char ch){
  2. //Check if the letter is between a to z
  3. return ( ch >= 'a' && ch <= 'z' )
  4. }
Last edited by BeyondTheEye; 26 Days Ago at 4:26 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 4
Reputation: tintin.iitk is an unknown quantity at this point 
Solved Threads: 0
tintin.iitk tintin.iitk is offline Offline
Newbie Poster
 
0
  #8
25 Days Ago
After looking at other posts and warnings, I have edited this post so as to remove half of the functions, so the person who started the thread has to do some of the work himself

  1. /**
  2. * file name: charRoutines.cpp
  3. * author: Nitin Garg
  4. */
  5.  
  6. #include "charRoutines.h"
  7.  
  8. #define NUM_CHARS 26
  9.  
  10. const char capChars[NUM_CHARS] = {
  11. 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
  12. 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
  13. 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
  14. 'Y', 'Z'
  15. };
  16. bool isUppercase( char c ) {
  17. //// basic code - no assumptions
  18. //for (int i = 0; i < NUM_CHARS; i++)
  19. // if (capChars[i] == c)
  20. // return true;
  21.  
  22. // complex code based on continuity assumption
  23. if (c >= 'A' && c <= 'Z')
  24. return true;
  25.  
  26. // Use either of the above two implementations
  27.  
  28. return false;
  29. }
  30.  
  31. #define NUM_VOWELS 5
  32. const char smallVowels[NUM_VOWELS] = {
  33. 'a', 'e', 'i', 'o', 'u'
  34. };
  35. bool isVowel( char c ) {
  36. // basic code - no assumptions
  37. for (int i = 0; i < NUM_DIGITS; i++)
  38. if ( smallVowels[i] == c))
  39. return true;
  40. //it's incomplete, complete it!
  41. return false;
  42. }
  43.  
  44. bool isSpace( char c ) {
  45. return (' ' == c);
  46. }
  47.  
  48. int toNumber( char c ) {
  49. if (!isNumeric(c))
  50. // unwanted input, other than 0-1
  51. // should throw some error
  52. return -1;
  53. else
  54. return static_cast<int>(c - digits[0]);//assuming that 0 is the first element in array, and numbers are allocated consecutively
  55. // alter
  56. //return static_cast<int>(c - '0');
  57. }
  58.  
  59. /**
  60. * Damn! Took me a good 20 minutes to think and type
  61. * haven't tested it though, that effort(testing and debugging) is left for you.
  62. */
Last edited by tintin.iitk; 25 Days Ago at 8:38 am.
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC