| | |
PLEASE HELP! very difficult Homework
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2009
Posts: 3
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Jul 2008
Posts: 139
Reputation:
Solved Threads: 14
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.
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.
•
•
Join Date: Nov 2009
Posts: 3
Reputation:
Solved Threads: 0
0
#4 26 Days Ago
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.
•
•
Join Date: Nov 2009
Posts: 3
Reputation:
Solved Threads: 0
0
#5 26 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.
-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 :
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 :
C++ Syntax (Toggle Plain Text)
bool isLowerCase(char ch){ //check if the ascii value of ch is between 97 and 122 return ( ch >= 97 && ch <= 122 ) }
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?
•
•
Join Date: Sep 2008
Posts: 55
Reputation:
Solved Threads: 10
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.
CPP Syntax (Toggle Plain Text)
bool isLowerCase(char ch){ //Check if the letter is between a to z return ( ch >= 'a' && ch <= 'z' ) }
Last edited by BeyondTheEye; 26 Days Ago at 4:26 am.
•
•
Join Date: Nov 2009
Posts: 4
Reputation:
Solved Threads: 0
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
C++ Syntax (Toggle Plain Text)
/** * file name: charRoutines.cpp * author: Nitin Garg */ #include "charRoutines.h" #define NUM_CHARS 26 const char capChars[NUM_CHARS] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; bool isUppercase( char c ) { //// basic code - no assumptions //for (int i = 0; i < NUM_CHARS; i++) // if (capChars[i] == c) // return true; // complex code based on continuity assumption if (c >= 'A' && c <= 'Z') return true; // Use either of the above two implementations return false; } #define NUM_VOWELS 5 const char smallVowels[NUM_VOWELS] = { 'a', 'e', 'i', 'o', 'u' }; bool isVowel( char c ) { // basic code - no assumptions for (int i = 0; i < NUM_DIGITS; i++) if ( smallVowels[i] == c)) return true; //it's incomplete, complete it! return false; } bool isSpace( char c ) { return (' ' == c); } int toNumber( char c ) { if (!isNumeric(c)) // unwanted input, other than 0-1 // should throw some error return -1; else return static_cast<int>(c - digits[0]);//assuming that 0 is the first element in array, and numbers are allocated consecutively // alter //return static_cast<int>(c - '0'); } /** * Damn! Took me a good 20 minutes to think and type * haven't tested it though, that effort(testing and debugging) is left for you. */
Last edited by tintin.iitk; 25 Days Ago at 8:38 am.
![]() |
Similar Threads
- We only give homework help to those who show effort (Computer Science)
- I am having homework isues. Please Help (Java)
- Error in class definition (C++)
- C++ Priority Queue and Heap help (C++)
- C++ Homework #1 (C++)
- Help needed: Complexity Big O(n) (Computer Science)
- Need Help on other homework (Computer Science)
Other Threads in the C++ Forum
- Previous Thread: how to display this shape using for loop?
- Next Thread: Initializing string with iterators
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game generator getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates text tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






