This program is going to be hawaiian word spell check, Written Hawaiian also has
ID: 3609749 • Letter: T
Question
This program is going to be hawaiian word spell check,Written Hawaiian also has fairly simple spelling rules fordetermining if a word is a valid word in the language (even if themeaning 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.
ex: it will read something like this:
this is not hawaiian word.
and print:
this it is invalid
is it is invalid
not it is invalid
hawaiian it is valid
word it is invalid
=====================================================================
I have written a program called is_vowel and is_h_consonant tocheck if they are.
I also have written a program called delimit_p to see if the inputis a delimiter.
This is the program I have so far, it does not work correctly.
main()
{
char ch;
char last_ch;
int inword;
int hi;
/* we are not in the word at thebeginning */
inword = FALSE;
/* we assume everything is nothawaiian word */
hi = FALSE;
/* set last character as avowel */
last_ch = 'a';
/* while there are morecharacters */
while((ch = getchar())!= EOF)
{
/* if not in word and not adelimiter */
/* then must be the beginnning of aword */
if (!inword && !delimitp(ch))
{
inword =TRUE; /* we are in a wordnow */
}
if(inword)
{
if(is_vowel(ch))
{ hi = TRUE; }
elseif(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(delimitp(ch)&& is_vowel(last_ch))
{ hi = TRUE; }
else { hi = FALSE ;}
putchar(ch);
}
last_ch = ch;
ch = getchar();
if (inword &&delimitp(ch)) /* if in word and a delimiter */
inword =FALSE; /* we are no longer in a word */
if(hi) {printf(" It isvalid!");} /* if it is correctspelling, print it's valid */
else {printf(" It is invalid!"); } /* if not,print it is invalid */
putchar(' '); /* print new line character */
hi = FALSE;
}
}
Super thanks for whoever that will spend time helping me onthis!!!
Explanation / Answer
#include<stdio.h>
#include <conio.h>
#include <ctype.h>
bool ishawaiian(char,int *);
int main()
{bool legal=true;
char ch;
intlast_ch=0,i;
char inword[20];
int kt=0,voc,done;
while((ch = getchar()) != EOF)
{inword[kt++]=ch;
if(ishawaiian(ch,&voc))
{if(voc==1)
if(kt!=1)
if(last_ch==1)
legal=false;
last_ch=voc;
}
else
{if(voc=3&&!(isspace(ch)||ispunct(ch)))
{legal=false;
done=0;
while(done==0)
{ch = getchar();
if(!(isspace(ch)||ispunct(ch)))
inword[kt++]=ch;
else
{done=1;
kt++;
}
}
}
kt--;
printf(" ");
for(i=0;i<kt;i++)
printf("%c",inword[i]);
if(legal)
printf(": it isvalid ");
else
printf(": it isinvalid ");
legal=true;
kt=0;
}
}
getch();
return 0;
}
bool ishawaiian(charch,int* voc)
{charletter[13]={'a','e','i','o','u','h','k','l','m','n','p','w','''};
int i;
for(i=0;i<13;i++)
{if(ch==letter[i])
{if(i<5)
*voc=0;
else
*voc=1;
returntrue;
}
}
*voc=3;
return false;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.