1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Elena-2011 [213]
3 years ago
15

Write a program that reads one or more strings from the standard input and outputs the count of vowels, consonants, and digit ch

aracters found in the stream.
Computers and Technology
1 answer:
Illusion [34]3 years ago
7 0

Answer:

endinput = "no"

mylist = []

vowel = ['a', 'e', 'i', 'o', 'u']

vowelcount = 0

consonantcount = 0

digitcount = 0

string = " "

number = [ str(i) for i in range(0, 10)]

while endinput == "no":

   inputs = input("Enter string value: ")

   mylist.append(inputs)

   endinput = input("Do you want to end input? ( enter no to continue:  ")

for item in mylist:

   txt = item

   print(txt)

   for i in txt:

       if i == string:

           continue

       elif i in vowel:

           vowelcount +=1

       elif i in number:

           digitcount += 1

       else:

           consonantcount += 1  

print("Vowels: ", vowelcount)

print("Digits: ", digitcount)

print("Consonant: ", consonantcount)

Explanation:

The python program receives one or more strings from the standard input and appends it to a list. The algorithm iterates through the list of string values and counts the number of vowels, consonants, and digits.

You might be interested in
Write a program that prompt the user to enter the coordinate of two points (x1, y1) and (x2,y2), and displays the slope of the l
zzz [600]

Answer:

Here is code in C++.

//include headers

#include <bits/stdc++.h>

using namespace std;

//main function

int main() {

//variables to store coordinates

float x1,x2,y1,y2;

cout<<"Please Enter the coordinate of first point (x1,y1): ";

// reading coordinate of first point

cin>>x1>>y1;

cout<<"Please Enter the coordinate of second point (x2,y2): ";

// reading coordinate of second point

cin>>x2>>y2;

//calculating Slope of the line that connects these points

float m=(x2-x1)/(y2-y1);

cout<<"Slope of the line that connects these two points is :  "<<m<<endl;

}

Explanation:

Declare four variables x1,x2,y1,y2 to store the coordinate of both points.

Read the coordinate of both the point from user. Calculate the slop of the

line which connects these two points with the formula m=(x2-x1)/(y2-y1).

Output:

Please Enter the coordinate of first point (x1,y1): 1 3                                                                                                        

Please Enter the coordinate of second point (x2,y2): 5 12                                                                                                      

Slope of the line that connects these two points is :  0.444444  

3 0
3 years ago
What is the Median Pay of Advertising, Promotions, or Marketing Managers?
NemiM [27]

Answer:

it is 125.510$ per yr but try B see if its correct

6 0
2 years ago
Read 2 more answers
Hiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
astra-53 [7]

Answer:

hhhhhhhhhhhhhhhhhiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii

Explanation:

5 0
2 years ago
Complete the function to replace any period by an exclamation point. Ex: "Hello. I'm Miley. Nice to meet you." becomes:
vodomira [7]

Answer:

Here is the complete function:

void MakeSentenceExcited(char* sentenceText) {  // function that takes the text as parameter and replaces any period by an exclamation point in that text

int size = strlen(sentenceText);  //returns the length of sentenceText string and assigns it to size variable

char * ptr;  // character type pointer ptr

ptr = sentenceText;  // ptr points to the sentenceText string

for (int i=0; i<size; i++){  //iterates through the sentenceText string using i as an index

    if (sentenceText[i]=='.'){  // if the character at i-th index of sentenceText is a period

        sentenceText[i]='!'; } } } //places exclamation mark when it finds a period at i-th index of sentenceText

Explanation:

The program works as follows:

Suppose we have the string:

sentenceText = "Hello. I'm Miley. Nice to meet you."

The MakeSentenceExcited method takes this sentenceText as parameter

int size = strlen(sentenceText) this returns the length of sentenceText

The size of sentenceText is 35 as this string contains 35 characters

size =  35

Then a pointer ptr is declared which is set to point to sentenceText

for (int i=0; i<size; i++) loop works as follows:    

1st iteration:

i=0

i<size is true because i=0 and size = 35 so 0<35

So the body of loop executes:

 if (sentenceText[i]=='.') statement checks :

if (sentenceText[0]=='.')

The first element of sentenceText is H

H is not a period sign so the statement inside if statement does not execute and value of i increments to 1. Now i = 1

2nd iteration:

i=1

i<size is true because i=1 and size = 35 so 1<35

So the body of loop executes:

 if (sentenceText[i]=='.') statement checks :

if (sentenceText[1]=='.')

This is the second element of sentenceText i.e. e

e is not a period sign so the statement inside if statement does not execute and value of i increments to 1. Now i = 2

So at each iteration the if condition checks if the character at i-th index of string sentenceText is a period.

Now lets see a case where the element at i-th index is a period:

6th iteration:

i=5

i<size is true because i=5 and size = 35 so 5<35

So the body of loop executes:

 if (sentenceText[i]=='.') statement checks :

if (sentenceText[5]=='.')

This is the character at 5th index of sentenceText i.e. "."

So the if condition evaluates to true and the statement inside if part executes:

sentenceText[i]='!'; statement becomes:

sentenceText[5]='!'; this means that the character at 5th position of sentenceText string is assigned an exclamation mark.

So from above 6 iterations the result is:

Hello!

This loop continues to execute until all the characters of sentenceText are checked and when the value of i gets greater than or equal to the length of sentenceText then the loop breaks.

The screenshot of the program along with its output is attached.

6 0
2 years ago
) Write a complete C++ program in one file which takes a double value from the user, cubes it, and prints the result. Your progr
Jet001 [13]

Answer:

The cpp program is given below.

#include <stdio.h>

#include <iostream>

using namespace std;

//function for cubing declared

double cubeValue(double n);

int main()

{

   //variable to hold user input

   double num;

   std::cout <<"Enter a number to be cubed: ";

   cin>>num;

   //variable to hold cube

   double cube;

   //function returns cube

   cube = cubeValue(num);

   std::cout <<"The cube of " <<num <<" is "<<cube <<std::endl;

   return 0;

}

//function to compute cube of the given parameter

//function definition

double cubeValue(double n)

{

   double d;

   d = n*n*n;

   return d;

}

OUTPUT

Enter a number to be cubed: 3.4

The cube of 3.4 is 39.304

Explanation:

1. The function for cubing is declared in the beginning of the program. The function has double return type as well as takes a double parameter. The function is defined after the main() method. The function only returns the cube of the double parameter passed to it.

double cubeValue(double n);

2. Inside main(), user input is taken for the number whose cube is to be computed.

3. The user input is taken in variable, num.

4. Another double variable, cube, is declared.

5. The method, cubeValue(), is called by passing variable num as parameter.

6. The value returned by the method, cubeValue() is assigned to the variable, cube.

cube = cubeValue(num);

7. The cube is displayed to the user using cout.

8. The program ends with return statement.

return 0;

The return statement assures successful execution of the program.

The program may not contain any syntax errors but contain logic errors which is indicated by the error message. The error message is displayed in red with return value -1.

9. The program is saved as cubeValue.cpp.

10. The method, cubeValue(), does not takes user input and does not prints any message.

11. The code is not written inside the class. The program contains only two methods.

12. The program can be tested for both integer and double values.

13. The program is written in cpp as per the requirements.

6 0
3 years ago
Other questions:
  • If you use a surrogate key, you must ensure that the candidate key of the entity in question performs properly through the use o
    5·1 answer
  • In one paragraph, explain how understanding social media influencing tactics has impacted the way you see social media posts in
    10·1 answer
  • Write a MARIE program to calculate some basic statistics on a list of positive numbers. The program will ask users to input the
    6·1 answer
  • A program needs to allow a customer to input integers until the input number is zero. When the input number is zero, the program
    14·1 answer
  • Ryan is working on a document with many secotions. For each section,he wantes to have the title bolded,underlined,an blue. Which
    9·2 answers
  • When you think of computers, I want you to think:
    7·1 answer
  • Select the correct answer.
    10·1 answer
  • '|'/2`/ '|'[] |)[-([]|)[- '|'#!$
    9·1 answer
  • ????????????helpppp please
    9·1 answer
  • (iii) ............ characters can be stored in memo field. (a) 50 (b) 64000 (c) 255 (d) 200 ​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!