Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project 6: String Programming Directions: Please complete the following assignment to signify your completion of Unit 11. All programming projects need to be completed and

Project 6: String Programming

Directions:

Please complete the following assignment to signify your completion of Unit 11. All programming projects need to be completed and submitted electronically, following the Electronic Submission Guidelines discussed in class. Please cherry-pick from your solution folder and submit just the .c files you created as well as the executable file created by your development environment.

Background:

The purpose of this assignment is to get practice working with strings. For this assignment, I'll be giving you some starter code. It sets up an string universe which will let you focus on working with strings and string parameters. From a C point of view, a string is just an array of characters. So working with strings seems very much like looping with an array.

Given the following starter code:

#include  /* function declarations - CS 50 Students need to implement this function */ /* from the string argument, it should return one of the following: */ /* 0 - name looks good!, as in "Howard Stahl" */ /* 1 - name has numbers in its value, as in "How123 Sta12" */ /* 2 - name has non-capitalized letters after a space, as in */ /* "howard stahl" */ /* 3 - name has non-capitalized letter as the first letter, as */ /* in "howard Stahl" */ /* 4 - name has non-alphanumeric characters, as in "#$5 Stahl" */ int validateName( char arr[] ); int main () { /* a string to hold 100 characters */ char data[ 100 ]; int value; printf( "Please enter your name: " ); fgets( data, 100, stdin ); /* or alternatively if you are using a Mac... */ /* #include  */ /* char * data = (char *) malloc( 100 * sizeof( char ) ); size_t bufsize; getline(&data,&bufsize,stdin); */ value = validateName( data ); switch( value ) { case 0: printf( "name passed all validation rules! " ); break; case 1: printf( "name has numbers, not only letters... " ); break; case 2: printf( "name has a letter following a space that is not capitalized... " ); break; case 3: printf( "name value does not start with a capital letter... " ); break; case 4: printf( "name has non-alphanumberic characters... " ); break; } return 0; } 

Please complete the declared function that have been stubbed out. By doing so, you will be working with strings and string arguments. I have supplied some sample output to help you understand the kind of code I am looking for.

SAMPLE RUN

Please enter your name: Howard Stahl name passed all validation rules! Please enter your name: 124%%$ 1347DD name has numbers, not only letters... Please enter your name: howard stahl name does not start with a capital letter... Please enter your name: (*&)_#$% name has non-alphanumeric characters... 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management System MCQs Multiple Choice Questions And Answers

Authors: Arshad Iqbal

1st Edition

1073328554, 978-1073328550

More Books

Students also viewed these Databases questions