Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Written Hawaiian also has fairly simple spelling rules for determining if a word is a valid word in the language (even if the meaning is

Written Hawaiian also has fairly simple spelling rules for determining if a word is a valid word in the language (even if the meaning is unknown). They are:

All words contain only vowels and Hawaiian consonants.

All words end in a vowel.

Within a word, two consonants NEVER appear adjacent.

Write a program which reads lines of Hawaiian text from a file (using redirection, so you will not need to prompt), and lists each word found on a separate line indicating whether it is a valid Hawaiian spelling or it is invalid. Any non-letter characters (e.g. white space or punctuation characters) in the file should be treated as delimiters, but otherwise ignored and not appear in the output.

I HAVE LETTERS.C AND LETTERS.H COMPLETED. I ALSO HAVE A LOT OF SPCHK.C COMPLETED BUT AM HAVING TROUBLE GETTING IT TO READ EACH INDIVIDUAL LETTER AND THUS PRINT OUT IF THE COMPLETE WORD IS VALID DETERMINED BY THE 3 PARAMETERS STATED IN THE QUESTION ABOVE. i'M JUST LOOKING FOR HELP ON FIXING THE SPCHK.C TO PRINT CORRECTLY. WE HAVE NOT LEARNED ARRAYS YET SO THEY CANNOT BE IN THE FILE.

Proper sample output: aloha mahalo alloha mahalot aloha It is valid! mahalo It is valid! alloha It is not valid! mahalot It is not valid!

letters.c

#include "letters.h"

int is_vowel(char c) { if ( c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U' || c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') { return 1; } else{

return 0; } } int is_h_consonant(char c)

{ if ( c == 'H' || c == 'h' || c == 'K' || c == 'k' || c == 'L' || c == 'l' || c == 'M' || c == 'm' || c == 'N' || c == 'n' || c == 'P' || c == 'p' || c == 'W' || c == 'w' || c == '`') { return 1; } else{

return 0; } }

/* This function return True if there is either whitespace or punctuators */

int whitespace(char c) { if(c == ' ' || c == '\t' || c == ' ') return 1; else return 0; }

int punctuation(char c) { if (c == '.' || c == ',' || c == ';' || c == '?' || c == '!') return 1; else return 0; }

int delimp(char c) { if(whitespace(c) || punctuation(c)) return 1; else return 0; }

letters.h

#define TRUE 1 #define FALSE 0

int is_vowel(char); int is_h_consonant(char); int delimp(char);

spchk.c

#include

#include "letters.h"

int main()

{

char ch;

char last_ch;

int inword;

int hi;

inword = FALSE;

hi = FALSE;

last_ch = 'a';

while((ch=getchar()) != EOF)

{

if( !inword && !delimp(ch))

{

inword = 1;

}

if(inword)

{

if(is_vowel(ch))

{ hi = TRUE;

}

else if(is_h_consonant(ch))

{

if((is_h_consonant(ch) &&

!is_h_consonant(last_ch))

|| (!is_h_consonant(ch) &&

is_h_consonant(last_ch)))

{ hi = TRUE;

}

}

else if(is_h_consonant(last_ch))

hi = FALSE;

else if(delimp(ch) && is_vowel(last_ch))

{ hi = TRUE;

}

else

{ hi = FALSE ;

}

}

if(inword && delimp(ch))

{

inword = 0;

if(hi)

printf("\t it is valid! ");

else

printf("\t It is invalid! ");

last_ch = ch;

hi = FALSE;

}

}

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

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

Students also viewed these Databases questions

Question

A study based on

Answered: 1 week ago