If you have any problem with the code feel free to comment.
Program
#include <iostream>
#include <string>
using namespace std;
int validateInput(string);
int charToInt(char);
int main()
{
string str;
//taking valid input
while(1)
{
cout<<"Enter a series of digits with no spaces between
them."<<endl;
getline(cin, str);
if(validateInput(str) == 0)
cout<<"Incorrect input.....?\n\n";
else
break;
}
int num;
int sum =0;
int low = charToInt(str[0]);
int high = charToInt(str[0]);
//find high and low and calculating sum
for(int i=0; i<str.size(); i++)
{
num = charToInt(str[i]);
sum += num;
if(low > num)
low = num;
if(high < num)
high = num;
}
cout<<"The sum of those digits is
"<<sum<<endl;
cout<<"The highest digit is "<<high<<endl;
cout<<"The lowest digit is "<<low<<endl;
return 0;
}
//for validating input
//return 0 when invalid
//return 1 when valid
int validateInput(string str)
{
for(int i=0; i<str.size(); i++)
{
if(str[i] < '0' || str[i] > '9')
{
return 0;
}
}
return 1;
}
//convert char to int
int charToInt(char ch)
{
int num = (ch - '0');
return num;
}
Output

c++ pleased Assignment 6a (15 points] - Character and String related processing... Listed below are two...
Design a program in pseudocode that asks the user to enter a string containing a series of ten single-digit numbers with nothing separating them. The program should display the sum of all the single digit numbers in the string except for the highest value digit. You may only use one main module and one sorting function; otherwise, do not modularize your program. For example, if the user enters 5612286470, the sum would be 33. (0+1+2+2+4+5+6+6+7) If there are multiple highest...
PLEASE HELP!!!I need help with the following JAVA PROGRAMS.
Please ready carefully. So this comes from tony
gaddis starting out with java book. I have included the screenshot
of the problems for reference. I need HELP implementing these two
problems TOGETHER. There should be TWO class files. One which has
TWO methods (one to implement problem 8, and one to implement
problem 9). The second class should consist of the MAIN program
with the MAIN method which calls those methods....
In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one character string. Using a single dimension array, populate the array with the character string, call a function using pointers to reverse order the character string, pass back to the main the output and total_count_of_characters. (maybe use a global variable for the total count). Print display the reversed char string and total_count.
In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one character string. Using a single dimension array, populate the array with the character string, call a function using pointers to reverse order the character string, pass back to the main the output and total_count_of_characters. (maybe use a global variable for the total count). Print display the reversed char string and total_count.
Write in C. Simple Program (beginner)
Assignment: Write a program Character Pointers and Functions. (like program #5-5). Keyboard input to enter one character string. Using a single dimension array, populate the array with the character string, call a function using pointers to reverse order the character string, pass back to the main the output and total_count_of_characters. (maybe use a global variable for the total count). Print display the reversed char string and total_count. <END>
Objectives: Use strings and string library functions. Write a program that asks the user to enter a string and output the string in all uppercase letters. The program should then display the number of white space characters in the string. You program should run continuously until the user enters an empty string. The program must use the following two functions: A function called count_spaces that counts the number of white spaces inside a string. int count_space(char str[]); which tell you...
please I need help with the question:
Problem: Write a C++ program that reads each character
from a user input, extracts the character if it is a digit, and
calculates the sum of all the digits. The program stops reading the
user input when the new line character ‘\n’ is encountered. For the
output of the program, you should print each digit extracted from
the user input and the sum of all the digits.
(*The main difference between “cin >>...
Intro to Programming in C – Large Program 1 – Character/ Number converter Assignment Purpose: To compile, build, and execute an interactive program with a simple loop, conditions, user defined functions and library functions from stdio.h and ctype.h. You will write a program that will convert characters to integers and integers to characters General Requirements • In your program you will change each letter entered by the user to both uppercase AND lowercase– o Use the function toupper in #include...
Write the code in python programming Language String Statistics: Write a program that reads a string from the user and displays the following information about the string: (a) the length of the string, (b) a histogram detailing the number of occurrences of each vowel in the string (details provided below), (c) the number of times the first character of the string occurs throughout the entire string, (d) the number of times the last character of the string occurs throughout the...
C Code Create a tool in which a user can enter a string (up to 25 characters) and choose how they wish to manipulate the string from a menu your program will display (see the run-through). The program will continue to ask for commands until the user enters the “quit” command. The commands are: • “Replace All” If a user types “replace all” using ANY sort of capitalization, your program will prompt the user to enter the character to change...