Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ with copyable code please!!!! . . . . . A. (27 Points) Write a complete, working C++ program called euidA.cpp (where euid is your

image text in transcribedc++ with copyable code please!!!!

. . . . . A. (27 Points) Write a complete, working C++ program called euidA.cpp (where euid is your EUID) that does the following: You need to find sum of digits in a string. The sum is either numeric sum or ASCII sum (See Sample Output). Declare an enumeration constant that can take two types of digit values Numeric, and ASCII. Assign characters 'N', and 'A' respectively to the data items. Declare a string variable to read a string from the user. Using suitable prompt, read a string from the user. The string can have multiple words, each word separated by a single space. Declare an integer variable named sum to store the sum of the digits of the string. Declare a character variable. This character variable will represent one of the two digit value types of your enumeration data. Using cin and cout statements, prompt the user to enter an appropriate character to select the character type. The user may choose to enter the character in either uppercase or lowercase but your program must work for either case. Design a switch-case block with a default case using your character variable as the switching expression. Your statements must have the enumeration constants -- Numeric, and ASCII-- as the case constants. For Numeric case, in a loop of your choice: Parse the string one character at a time. Check if the character is a digit. If it is, find the numeric value of the digit. HINT: The ASCII value of character 'O' is 48, while the numeric value is 0. Accumulate the numeric value in the sum variable. o For ASCII case, in a loop of your choice: Parse the string one character at a time. Check if the character is a digit. If it is, accumulate the ASCII value of the digit in the sum variable. Use the default case to inform the user if the user makes the wrong selection of character type. Display the computed sum using with a suitable message. Due to time constraints, no comments are required in this code. o 1 o

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

How the bidding process works

Answered: 1 week ago

Question

Determine the amplitude and period of each function.

Answered: 1 week ago