C++ :: Read User Input - Count And Display Vowels
Sep 26, 2012
I'm trying to code a program to read the user's input and have it:
-count vowels
-stop counting vowels after '.' or '?' (ie. abcdjwef is 1 a, 1 e; while fje.fwdfeiii is just 1 e)
-closes when ENTER is pressed after a '.' or '?' is found (ie. closes after 'abacds. ENTER' as well as 'as.fefsdf ENTER')
-display the number of vowels
Is there any way to do this with only 'cin >> userInput' and a while loop checking for punctuation?
View 1 Replies
ADVERTISEMENT
Oct 7, 2013
The output I'm getting here just counts every letter in the sentence and counts them as vowels. I'm trying to make the user defined function return the amount of vowels within the sentence.
#include <iostream>
#include <iomanip>
#include <cmath>
[Code].....
View 4 Replies
View Related
Mar 30, 2013
I am trying to create a code that simply counts the number of vowels inputted by the user. Here's where I am.
Code:
#include <iostream>
using namespace std;
bool isVowel(char ch);
int main() {
int count=0;
char character;
int vowelcount=0;
[Code] .....
View 14 Replies
View Related
Feb 11, 2013
I need to write a program using at least one while loop to count and display the amount of vowels in a user input string. This is what I have so far.
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int acounter(0); // Create counters for each vowel
[Code] ....
View 2 Replies
View Related
Aug 13, 2013
how to remove the vowels from the user input.?
View 4 Replies
View Related
Feb 4, 2013
Code:
#include <stdio.h>
main() {
int c, n1;
n1 = 0;
while ((c = getchar()) != EOF)
if (c == '')
++n1;
printf("%d", n1);
}
I have a more complicated program I'm wishing to have display the output, however, to save some time I'm using an example of a shorter version. count the lines in input and display the output in terminal when ./program is executed after compilation. To count and compute lines, words and within arrays.
View 4 Replies
View Related
Jul 14, 2014
In this assignment, you must enter a file and get out of it this:
Summary
Total characters: 8282
Vowels: 2418
Consonants: 3970
Letters: 6388
Digits: 174
Left parentheses: 17
Right parentheses: 17
Single quotes: 17
Double quotes: 14
Other: 1655
Here is my code:
#include <iostream>
#include <fstream>
#include <cctype>
using namespace std;
char ch;
bool isVowel (char);
[Code] .....
View 2 Replies
View Related
Feb 22, 2015
In this program, I am suppose to input a string, then have a menu that I can input A, B, C, D, E. A is suppose to be a function that counts the vowels within the string. B is suppose to be a function that counts the consonants. C. is suppose to display both functions. D. is suppose to let you input a new string. And E. is suppose to just exit the program. I am having trouble with the pointers with the functions, vowCounter and conCounter. My visual basic will not debug it if I choose A, B, or C.
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int* vowCounter(string, int);
int* conCounter(string, int);
[Code] ....
View 5 Replies
View Related
Apr 28, 2014
I am writing a music program that will read (from a separate file) a guitar chord and display it to the the user. The format of the separate text file is as follows:
A
|--0--|
|--2--|
|--2--|
|--2--|
|--0--|
|--x--|
B
|--2--|
|--4--|
|--4--|
|--4--|
|--2--|
|--x--|
C
|--0--|
|--1--|
|--0--|
|--2--|
|--3--|
|--3--|
etc...
I want the user to be able to search for a specific chord in the file and how I can make that happen.
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;
[Code] .....
View 2 Replies
View Related
Apr 5, 2013
If the user puts in a 6. I need the array to display the even number from 0 - 6. Right now what it does is it displays the first six even numbers. Okay as I'm writing this I'm starting to see where my problem might be..
Code:
void sumIntegers () {
int arr[50];
int i = 0;
int num = 0;
int sum = 0;
[Code] .....
View 1 Replies
View Related
Mar 17, 2013
I am having problems printing "->" on the beginning of each line, im trying to do it as a loop and ending it when the user types "q". also i would like to know how to ignore text from the user when the input begings with a specific character. heres what ive done so far, and not currrently working as expected.
Code:
#include <stdio.h>
int main (void) {
char prompt;
printf("~~~ FRACTION CALCULATOR ~~~
[Code] ....
View 1 Replies
View Related
Mar 13, 2014
How can i write a program that allows a user to enter a size of pizza and then print the price for that size.
Example: if a user enters size ''s'' then it should display the price stored under ''s''
View 3 Replies
View Related
Jan 10, 2015
I'm coding a hangman game. I'm trying to store user entries so i can output them to show the user what they have already entered. Problem is that it's not display anything at all.
I'm trying to store multiple characters of course, and then display all characters stored.
char guess[27]={0};
cin >> guess[26];
int hit=0;
for(int i=0; i<len; i++) {
if( guess[26] == hidden_word[i] ) {
hit++;
select_word[i] = guess[26];
if(strcmp(hidden_word,select_word) == 0) {
[code]....
EDIT: I also get the error - Stack around the variable 'guess' was corrupted. At the end of the game.
View 6 Replies
View Related
May 29, 2014
How do I change User Input to display in Italic font style?
Let's say user inputs a word, then display that word in italic font.
View 3 Replies
View Related
Mar 10, 2014
i want to display all the contents of a file excluding one based on user input say i have 4 records in the file numbered 1 to 4....the user chooses 2 to exclude it outputs records 1,3,4,4 when it should be records 1,3,4 what am i doing wrong here is the code.its basically displaying the last record in the file twice
void excludeRecord()
{
ifstream read;
read.open("Data.txt");
int recordC =0;
string fnameC = " ";
string lnameC = " ";
[Code]...
View 2 Replies
View Related
Jul 29, 2013
I'm suppose to write a program using (for loop) that asks the user to enter any amount of numbers, so that it can display the smallest and largest. My program successfully finds the largest, but it is always displaying 0 for the smallest, I think Im doing something wrong with the internalization but I dont know what to change it to.
This is what I have ....
#include <iostream>
using namespace std;
int main() {
int amount;
int count;
int number = 0;
int smallest = 0;
int largest = 0;
cout << "Enter total numbers to process: ";
[Code] ....
View 4 Replies
View Related
Aug 26, 2013
I am having a problem printing out the results for my code, It is supposed to print out the largest and smallest value in the array, but keeps giving me a value not entered and I don't know why.
//This program lets the user enter 10 numbers and then display the highest and lowest number.
#include <iostream>
#include<stdio.h>
using namespace std;
int main() {
const int NUM_ENTERED = 9;
int number[NUM_ENTERED], highestValue = number[0], lowestValue = number[0], count=0;
[Code] .....
View 2 Replies
View Related
Jan 18, 2014
It's a tic-tac-toe program. I haven't finished doing everything I need to for the project, I'm just trying to get certain parts working as I go.
Anyway, my problem: The program will print the board and ask the first player which square they want to mark. Then it will print the updated board, print the question for the second player to input their square choice but not actually stop to let the user enter anything. Instead it prints the board again and then prints the question for player one again -- this time stopping to let them type in their choice.
Here's my code:
#include <stdio.h>
// Function prototypes
void printBoard(char board[3][3]);
int main() {
int quit = 0;
// Loop so game continues until player quits
[Code] .....
And it looks like this when I run it, as an example:
-------------
| 1 | 2 | 3 |
-------------
| 4 | 5 | 6 |
-------------
| 7 | 8 | 9 |
-------------
Player 'C' enter a square: 5
-------------
| 1 | 2 | 3 |
-------------
| 4 | C | 6 |
-------------
| 7 | 8 | 9 |
-------------
Player 'U' enter a square:
-------------
| 1 | 2 | 3 |
-------------
| 4 | C | 6 |
-------------
| 7 | 8 | 9 |
-------------
Player 'C' enter a square:
View 11 Replies
View Related
Mar 13, 2013
how to read characters from user and construct a sting and then extract part of it using substring?
View 2 Replies
View Related
Apr 6, 2014
My program is designed to read input from the user and then store that input in a structure variable. Whenever i use the cin.getline() function, it comes up with a semantic issue. Here is the code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
const int DESCRIPTION_SIZE = 100, DATE_SIZE = 20;
struct inventory {
string description[DESCRIPTION_SIZE];
[Code] .....
I left out the other functions. The error reads "no matching member function for call to 'getline'.
View 6 Replies
View Related
Aug 5, 2014
I'm having a problem with the two while statements in my UDF.
- 1. It will run both while loops twice...?
- 2. It now goes into a continuous loop.
- 3. When it did work, it would only return 1 value to the main()...?
#include <iostream> // for use of "cin" & "cout", endl...
#include <iomanip> // for formatting setw function
#include <cmath> // for the general math computations
#include <string> // for creating descriptive strings
#include <sstream> // used to convert a string to an integer
//user defined function
int userValue (int);
[code].....
View 1 Replies
View Related
Mar 26, 2013
The program should find and delete all vowels in a word that is user entered. This is what I have so far and I know it should be essentially this format I just don't know how to set enteredword and word equal to each other.
#include <string>
#include <iostream>
using namespace std;
void vowelremover(string&);
int main () {
string word;
[Code] ....
View 3 Replies
View Related
Mar 25, 2013
The program should find and delete all vowels in a word that is user entered. This is what I have so far and I know it should be essentially this format I just don't know how to set entered word and word equal to each other.
Code:
#include <string>
#include <iostream>
using namespace std;
void vowelremover(string&);
string word;
int main ()
{//string word;
[Code]....
View 3 Replies
View Related
Apr 19, 2013
I have a list of objects that I need to read information from each object to compare to a user input prompt.
#include "Passenger.h"
#include "Reservation.h"
#include "Aircraft.h"
#include <iostream>
#include <fstream>
#include <string>
#include <list>
using namespace std;
//Function Prototypes
void flightRoster(list<Reservation>&);
[Code] ....
View 1 Replies
View Related
Nov 18, 2014
I have to create a program that incorporates an array of structures in order to simply read input from the user and then reprint that information to the screen. This is a fairly simple problem, but the issue is that the professor requires that we solve it in a very specific way.
I must have three functions in total: one to receive input from the user, one to print the received values, and of course the main function which calls the other two. Also, the input and output functions must be defined using the following prototypes:
void inputData(Component C1);
void printData(Component *C1);
Where Component is a structure defined above as:
typedef struct// Component {
float cost;
int code;
char name[30];
[Code] ....
I know that this problem could be easily solved by simply passing the entire 'comp' array to the inputData function, or passing a pointer to it, or having it return a pointer, but I am not allowed to do any of these things. I must use the function as defined by the prototype.
View 3 Replies
View Related
Jun 23, 2014
it will not run and im not sure why. I have a couple of errors, but I'm not sure why.
Here is my code.
//Reads input from user to determine different discounts by number of units sold
#include <iostream>
#include <string>
using namespace std;
int main() {
//Declaration and Initialization of variables
int quantity;
double discount,price = 99.00,totalCost;
[Code] ....
View 1 Replies
View Related