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

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.

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.

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.

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

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 :

bool isLowerCase(char ch){
   //check if the ascii value of ch is between 97 and 122
    return ( ch >= 97 && ch <= 122 )
}

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.

bool isLowerCase(char ch){
      //Check if the letter is between a to z
      return ( ch >= 'a' && ch <= 'z' )
}

Edited 7 Years Ago by BeyondTheEye: n/a

Comments
like he/she read my mind and said what i was just gonna say.

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

/**
* 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.
*/

Edited 7 Years Ago by tintin.iitk: n/a

This article has been dead for over six months. Start a new discussion instead.