User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 392,050 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,333 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:
Views: 1395 | Replies: 8
Reply
Join Date: Oct 2004
Posts: 43
Reputation: hopeolicious is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
hopeolicious hopeolicious is offline Offline
Light Poster

I need help

  #1  
Nov 5th, 2004
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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2004
Location: Marin, CA, USA
Posts: 434
Reputation: Chainsaw is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 10
Chainsaw's Avatar
Chainsaw Chainsaw is offline Offline
Unprevaricator

Re: I need help

  #2  
Nov 5th, 2004
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;
}
Reply With Quote  
Join Date: Oct 2004
Posts: 43
Reputation: hopeolicious is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
hopeolicious hopeolicious is offline Offline
Light Poster

Re: I need help

  #3  
Nov 5th, 2004
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
Reply With Quote  
Join Date: Nov 2004
Posts: 45
Reputation: jifiii is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
jifiii jifiii is offline Offline
Light Poster

Re: I need help

  #4  
Nov 5th, 2004
ok, here is an hint, look on the ASCII table for vowels, if that doesn't reply back and I will tell u more.
Reply With Quote  
Join Date: Sep 2004
Posts: 6,022
Reputation: Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of 
Rep Power: 26
Solved Threads: 414
Super Moderator
Narue's Avatar
Narue Narue is online now Online
Expert Meanie

Re: I need help

  #5  
Nov 5th, 2004
>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.
Member of: Beautiful Code Club.
Reply With Quote  
Join Date: Oct 2004
Posts: 43
Reputation: hopeolicious is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
hopeolicious hopeolicious is offline Offline
Light Poster

Re: I need help

  #6  
Nov 7th, 2004
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
Reply With Quote  
Join Date: Oct 2004
Posts: 43
Reputation: hopeolicious is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
hopeolicious hopeolicious is offline Offline
Light Poster

Re: I need help

  #7  
Nov 8th, 2004
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);
}
Last edited by alc6379 : Nov 8th, 2004 at 3:11 pm. Reason: added [code] tags
Reply With Quote  
Join Date: Oct 2004
Posts: 43
Reputation: hopeolicious is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
hopeolicious hopeolicious is offline Offline
Light Poster

Re: I need help

  #8  
Nov 9th, 2004
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);
}
Reply With Quote  
Join Date: Jun 2004
Location: Marin, CA, USA
Posts: 434
Reputation: Chainsaw is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 10
Chainsaw's Avatar
Chainsaw Chainsaw is offline Offline
Unprevaricator

Re: I need help

  #9  
Nov 9th, 2004
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++;
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C++ Marketplace
Thread Tools Display Modes

Other Threads in the C++ Forum

All times are GMT -4. The time now is 11:32 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC