Hi all
I hope that maybe one of you is nice enough to give me a nudge in the right direction with this assignment I am working on. I have been given a program shell that is incomplete and asked to finish it. At the moment I feel completely stuck in never never land and I cant seem to get my head around any of it.
Some suggestions and help would be most appreciated.
Here is the assignment if you could please take the time to look over it:
Thanks
Smurphygirl
p.s. dont hate me if i didnt get the code tag right. I did try
Code:
#include "copyio.h"
#include <string.h>
#include <ctype.h>
//function prototypes
void outputHeader(void);
int getText(char input[]);
int offerMenu(void);
void implementChoice(int length, int choice, char input[]);
int countPunct(int length, char input[]);
int checkIfPalindrome(int length, char input[]);
void printAsciiBinary(int length, char input[]);
/******************************************************************************
main
The main function.
Calls outputHeader, getText, offerMenu, implementChoice.
******************************************************************************/
int main (void)
{
int lengthOfInput;
int inputChoice;
char inputString[81]; //80 character limit on text input
int quit;
outputHeader();
lengthOfInput = getText(inputString); //prompts for and gets an input string
//and its length
quit = 0;
inputChoice = 0;
while (!quit)
{
inputChoice = offerMenu();
implementChoice(lengthOfInput, inputChoice, inputString);
if (inputChoice == 5)
{
quit = 1;
printf("Program terminated.\n");
}
}
return (0);
}//end of main
/******************************************************************************
outputHeader
Displays the program heading.
Called by main.
******************************************************************************/
void outputHeader(void)
{
}//end of outputheader
/******************************************************************************
getText
Gets the text from the input stream and stores it in the "input" string.
Assumes text input is limited to one line of up to 80 characters.
Called by main.
Calculates the length of the string.
Receives base address of "input" string.
Returns inputLength.
******************************************************************************/
int getText(char input[])
{
int inputLength;
printf("Enter text to be processed (1 line up to 80 characters): \n");
printf("> ");
gets(input);
inputLength = strlen(input);
return (inputLength);
}//end of getText
/******************************************************************************
offerMenu
Displays menu of text processing and quit options.
Called by main.
Returns user's choice.
******************************************************************************/
int offerMenu(void)
{
int choice;
printf("\n\nMenu:\n");
printf(" 1: Count characters (including white spaces)\n");
printf(" 2: Count punctuation marks\n");
printf(" 3: Check if palindrome\n");
printf(" 4: Print table of characters in ascii and binary\n");
printf(" 5: Quit\n");
printf("\n> ");
scanf("%d", &choice);
return (choice);
}//end of offerMenu
/******************************************************************************
implementChoice
Implements the user's choice of text processing or quitting program.
Called by main.
Calls countPunct, checkIfPalindrome, printAsciiBinary.
Displays results.
Receives length of input string, user's choice, base address of input string.
******************************************************************************/
void implementChoice(int length, int choice, char input[])
{
}//end of implementChoice
/******************************************************************************
countPunct
Counts the number of punctuation characters in the input string.
Called by implementChoice.
Receives length of input string and base address of input string.
Returns number of punctuation characters in the input string.
******************************************************************************/
int countPunct(int length, char input[])
{
}//end of countPunct
/******************************************************************************
checkIfPalindrome
Checks if the input string is palindrome.
Called by implementChoice.
Receives length of input string and base address of input string.
Returns value of isPalindrome.
******************************************************************************/
int checkIfPalindrome(int length, char input[])
{
}//end of checkIfPalindrome
/******************************************************************************
printAsciiBinary
Prints a table of each character in the input string along with its ascii and
binary values.
Called by implementChoice.
Receives length of input string and base address of input string.
******************************************************************************/
void printAsciiBinary(int length, char input[])
{
}//end of printAsciiBinary