Write a program with a function that accepts a string as an argument and returns a copy of the string with the first character of each sentence capitalized. For instance, if the argument is “hello. my name is Joe. what is your name?” the function should return the string “Hello. My name is Joe. What is your name?” The program should let the user enter a string and then pass it to the function. The modified string should be displayed.
Please find your solution written in JAVA:
import java.util.*;
// Java program to convert first character uppercase in a
sentence
public class Conversion {
static String convert(String inputStr)
{
// Create a character array of given String
char chArr[] = inputStr.toCharArray();
for (int j = 0; j < inputStr.length(); j++) {
// If first character of a word is found
if (j == 0 && chArr[j] != ' ' ||
chArr[j] != ' ' && chArr[j - 1] == ' ') {
// If it is in lower-case
if (chArr[j] >= 'a' && chArr[j] <= 'z') {
// Convert into Upper-case
chArr[j] = (char)(chArr[j] - 'a' + 'A');
}
}
// If apart from first character, any 1 is in Upper-case
else if (chArr[j] >= 'A' && chArr[j] <= 'Z')
// Convert into Lower-Case
chArr[j] = (char)(chArr[j] + 'a' - 'A');
}
// Convert the char array to equivalent String
String str = new String(chArr);
return str;
}
public static void main(String[] args)
{
Scanner sc= new Scanner(System.in); //System.in is a standard input
stream
System.out.print("Enter a string: "); // asking user to enter the
string
String str= sc.nextLine();
System.out.println(convert(str)); // calling the convert function
and printing the result
}
}
CONSOLE OUTPUT:


Write a program with a function that accepts a string as an argument and returns a...
1. Write a function called ordinal_sum that accepts a string argument and returns the sum of the ordinal values of each character in the string. The ordinal value of a character is its numeric Unicode code point in decimal. 2. Write code that creates a Python set containing each unique character in a string named my_string. For example, if the string is 'hello', the set would be {'h', 'e', 'l', 'o'} (in any order). Assign the set to a variable...
write a C++ function that accepts a pointer to a C-string as an argument and displays its contents backward. For instance, if the string argument is “ Gravity ” the function should display “ ytivarG ”. Demonstrate the function in a program that asks the user to input a string and then passes it to the function.
1. String Length Write a function that returns an integer and accepts a pointer to a C-string as an argument. The function should count the number of characters in the string and return that number. Demonstrate the function in a simple program that asks the user to input a string, passes it to the function, and then displays the function’s return value. c++
using c++ program
write this program without the optional exercise
3. Word Counter Write a function that accepts a pointer to a C-string as an argument and returns the number of words contained in the string. For instance, if the string argument is "Four score and seven years ago” the function should return the number 6. Demonstrate the function in a program that asks the user to input a string and then passes it to the func tion. The number...
Write a function that accepts a pointer to a C-string as its argument. The function should count the number of times the character 'w occurs in the argument and return that number.
Write a function called smallestLetter that takes in a string argument and returns a char. The char that is returned by this function is the character in the string with the lowest ASCII integer code. For example: smallestLetter("Hello") returns ‘H’ which is code 72, and smallestLetter("Hello World") returns ‘ ’ (The space character) which is code 32
Write two versions of the function mostFrequentCharacter, one that accepts a C-string and one that accepts a string object, as its argument. The function should return the character that appears most frequently in the string. Demonstrate the function in a complete program. Do not use any string or cstring functions in the cstring version.
python In a program, write a function named roll that accepts an integer argument number_of_throws. The function should generate and return a sorted list of number_of_throws random numbers between 1 and 6. The program should prompt the user to enter a positive integer that is sent to the function, and then print the returned list.
write a function which takes a string argument and a character argument. It should return a truth value (int 0 or 1), 0 if the string does not contain the character, and 1 if the string does contain the character. Do not use a built-in library for this. Again, call this function and its variables whatever you deem appropriate. The main function of the program should accept a single character followed by Enter. Then, it will read lines until the...
The problem is this Design a function that accepts a list as an argument and returns the largest value in the list. The function should use recursion to find the largest item. My coding so far is this def main(): # Prints the largest value in list user_input = input('Enter a list of numbers seperated by a space: ') user_list = user_input.split() print('Largest number is ', max_Number(user_list), '.') # Recursion function that finds the maximum number in a sequence of...