>no help at all...but thanks anyway.
Your capacity for patience is staggering. I mean, you couldn't even wait a full hour when it's either SUNDAY, or the wee hours of Monday all over the world. Good luck passing your class, and succeeding at a programming career, because you'll clearly need it. :icon_rolleyes:
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
As a general note if you want people to read your code learn to format it in a clean way. Having bad indents and no white space and cramming everything onto one line by throwing in semi-colons makes it just as hard to read if you don't use code tags and in the end when you compile this cutting out lines just makes it harder for you to go back to and fix up and will not make your file size any smaller.
I commented a few lines telling you what I did.
#include "stdafx.h"
#include <string>
#include <iostream>
using namespace std;
class vowels
{
string input;
int a, e, i, o, u, y;
public:
vowels();
void getdata();
void processdata();
void display();
};
vowels::vowels()
{
a = 0, e = 0, i = 0, o = 0, u = 0, y = 0; //made is so you dont redeclare the variables
input = " ";
getdata(); //when you make the variable class it auto starts the input instead of calling this function in main
}
void vowels::getdata()
{
cout << "Enter String of Characters->> ";
getline(cin,input);
processdata(); //after input the vowel checker starts
display(); //after vowel checker displays the data
}
void vowels::processdata()
{
for( int x = 0; x < input.length()-1; x++ ) //added a for() loop for checking the string char by char not comparing the whole string
{
if( input[x] == 'A' || input[x] == 'a' ) //checks index 'x' and compares to a char not a string
{
a++; //a=a++; is exacly the same as saying a = a+1; and is the same as putting a++;
}
else if( input[x] == 'E' || input[x] == 'e' )
{
e++;
}
else if( input[x] == 'I' || input[x] == 'i' )
{
i++;
}
else if( input[x] == 'O' || input[x] == 'o' )
{
o++;
}
else if( input[x] == 'U' || input[x] == 'u' )
{
u++;
}
}
}
void vowels::display()
{
printf("Vowels present in the typed string are:\n");
cout << "A=" << a << endl;
cout << "E=" << e << endl;
cout << "I=" << i << endl;
cout << "O=" << o << endl;
cout << "U=" << u << endl;
}
int main()
{
vowels countvowels; //everything is called within the class after this is declared
system("pause");
return 0;
}
sfuo
Practically a Master Poster
656 posts since Jul 2009
Reputation Points: 164
Solved Threads: 99