Can someone give me a start of my program

I have to write a program usig functions that will read in an array of text and using the case statement determine the number of capital and lowercase letters(a, e, i, o, and u's) found in a string of text with the array 500 and calculate the total number of vowels found in the text. The program shouls allow a user to input a string of text calculate the number of each vowels found in thee text. Then prompt to continue or discontue the process. In the output I have to also promt the user to see if they would like to continue with another input process.

Can someone walk me through the process(something like tutor me) of this because I am so confused I dont know where to start or how to start. we can walk through it on here or we can walk through email but please someone help me with this.

Dave Sinkula commented: "I have no idea where to begin" is very lame. That is page 1 in any C book. And email requests are also in poor taste. +0

Recommended Answers

All 8 Replies

which part do you need help with? The switch?

switch (theChar)
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
// increment the counter for lower-case vowels
break;

case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
// increment the value for uppercase vowels
break;

default:
break;
}

like I dont know how this program is suppose to go I had an idea for the case statement but the calclating of the upper and lower and vowels I do not have the slightest clue to how to do any of it

ok, here is an hint, look on the ASCII table for vowels, if that doesn't reply back and I will tell u more.

>look on the ASCII table for vowels
No, this encourages bad practice. Not all implementations use the ASCII character set, so the trick of subtracting 'A' from 'a' or 'a' from 'A' is nonportable and thus, not recommended. Especially for one new to the language.

>I do not have the slightest clue to how to do any of it
Can you give us an example of the input and output of this program? Because the way you're describing it could mean several mutually exclusive problems. I would much rather address the problem you really have as opposed to a problem I may think you have because I didn't understand your question.

Ok I kind of wrote a program of how I think that it goes but i'll have to post it on tomorrow around 1pm I have it wrote in my tablet but its like this

you have to set the message to an array of only 500. In the line of text inputted from the user the program have to count the amount of upper and lowercase letter vowels and then output the # of each vowel seperately example:

switch(char)
{
case 'a': case 'A':
amount of a's = whatever;
case 'e': case 'E':
amount of e's = whatever;
i
o
u
}

and so on, then it should output the # of each and the total number of all
and after that it has to total the # of words in the text.

I have a sense of how the program is I wrote it down in my tablet but i never put it into the computer to compile it but i'm doing that tomorrow after class so i'll post what I have and we can go from there but I think I got it.

Thanx everyone

This is what i have but it is like so wrong when I compiled it but I said I was going to post what I had so Imma finish this up and make my corrections and post what I come up with on tomorrow

#include<iostream.h>

char ch_option;
const int MAXCHARS = 500;
char st_line[MAXCHARS];
static const int i_number = 0;
static const int i_vowel = 0;
char ch_char;
int i_count;
int i_word;
int i_va;
int i_ve;
int i_vi;
int i_vo;
int i_vu;


void getdata();
void vowels(char []);
void words();
void putdata();


int main()
{
do{
getdata();
vowels(char []);
words();
putdata();
}while(ch_option != 'Y');
        return 0;
}

void getdata()
{
        cout << "\nPlease enter line of text:\n\n";
        cin.getline(st_line,MAXCHARS);
        vowels(st_line);
        cin.get();
}

void vowels(char [])
{
while((ch_char = st_line[i_number] != '\0');
switch(ch_char)
{
        case 'a': case 'A':
        i_va = ch_char;
        case 'e': case 'E':
        i_ve = ch_char;
        case 'i': case 'I':
        i_vi = ch_char;
        case 'o': case 'O':
        i_vo = ch_char;
        case 'u': case 'U':
        i_vu = ch_char;
        i_vowel++;
}
        return;
}

void words()
{
if(st_line[i_word} == ' ' || st_line[i_word] == '\0')
        count--;
while(st_line[i_word] != '\0')
{
if(st_line[i_word] == ' ' && (st_line[i_word + 1] != ' ' && st_line[i_word = 1}
!= '\0'))
        i_count++;
        i_word++;
}
        return;
}

void putdata()
{
        cout << "\nInputted String";
        cout << "\n\n*******************************";
        cout << "\n\n " << st_line;
        cout << "\n\nNumber of a's: " << i_va;
        cout << "\nNumber of e's: " << i_ve;
        cout << "\nNumber of i's: " << i_vi;
        cout << "\nNumber of o's: " << i_vo;
        cout << "\nNumber of u's: " << i_vu;
        cout << "\nTotal Vowels: " << i_vowels;
        cout << "\n\nNumber of Words: " << i_word:
        cout << "\n\n\nDo you want to exit (Y/N)? ";
        cin.get(ch_option);
}

ok this is syntax prrof but it is logically wrong
1. my do while statement doesnt work it keeps outputting my output
2. andit counts my vowels and wrods wrong

can someone please help me

#include<iostream.h>
#include<stdlib.h>

const int MAXCHARS = 500;
char st_line[MAXCHARS];
char ch_option;
int i_va;
int i_ve;
int i_vi;
int i_vo;
int i_vu;
int i_word;
int i_count = 1;
int i_number = 0;
int i_vowel = 0;
char ch_char;


void getdata();
void vowels();
void words();
void putdata();

int main()
{
do{
getdata();
vowels();
words();
putdata();
}while(ch_option != 'y');
}

void getdata()
{
        cout << "\nPlease enter line of text:\n";
        cin.getline(st_line,MAXCHARS);
        vowels();
}

void vowels()
{

while((ch_char = st_line[i_number++]) != '\0')
switch(ch_char)
  {
        case 'a': case 'A':
          ch_char = i_va;
        case 'e': case 'E':
          ch_char = i_ve;
        case 'i': case 'I':
          ch_char = i_vi;
        case 'o': case 'O':
          ch_char = i_vo;
        case 'u': case 'U':
          ch_char = i_vu;
        i_vowel++;
  }
        return;
}

void words()
{

if(st_line[i_word] == ' ' || st_line[i_word] == '\0')
        i_count--;
while(st_line[i_word] != '\0')
 {
  if(st_line[i_word] == ' ' && (st_line[i_word + 1] != ' ' && st_line[i_word + 1
] != '\0'))
        i_count++;
        i_word++;
  }
        return;
}


void putdata()
{
        cout << "\nInputted String";
        cout << "\n\n*******************************";
        cout << "\n\n " << st_line;
        cout << "\n\nNumber of a's: " << i_va;
        cout << "\nNumber of e's: " << i_ve;
        cout << "\nNumber of i's: " << i_vi;
        cout << "\nNumber of o's: " << i_vo;
        cout << "\nNumber of u's: " << i_vu;
        cout << "\nTotal Vowels: "<< i_vowel;
        cout << "\n\nNumber of Words: " << i_word;
        cout << "\n\n\nDo you want to exit (Y/N)? ";
        cin.get(ch_option);
}

switch(ch_char)
{
case 'a': case 'A':
ch_char = i_va;
case 'e': case 'E':
ch_char = i_ve;
case 'i': case 'I':
ch_char = i_vi;
case 'o': case 'O':
ch_char = i_vo;
case 'u': case 'U':
ch_char = i_vu;
i_vowel++;
}

Don't you want to increment i_va through i_vu? Rather than assign them to ch_char? And if you don't add any 'break' statements, then when you get an 'a' you will increment everything BELOW the 'a' too. What you want is something more like:

bool vowel = false;
switch (ch_char)
{
    case 'a': 
    case 'A':
        i_va++;
        vowel = true;
        break;

    case 'b':
       <etc>
}
if (vowel)
    i_vowell++;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.