[Solved] CS1114-Homework 4- an expression to print the string from the middle character to the end

$25

File Name: CS1114-Homework_4-_an_expression_to_print_the_string_from_the_middle_character_to_the_end.zip
File Size: 838.38 KB

SKU: [Solved] CS1114-Homework 4- an expression to print the string from the middle character to the end Category: Tag:
5/5 - (1 vote)

Homework 4

Question 1(From the textbook, page 219, question 4) Ask user to input a string S of odd length:(a) Write an expression to print the middle character.(b) Write an expression to print the string up to but not including the middle character (i.e., thefirst half of the string).(c) Write an expression to print the string from the middle character to the end (not including themiddle character).Sample output:Enter a string: Fortune favors the boldMiddle character: oFirst half: Fortune favSecond half: rs the boldQuestion 2Ask user to input a character and classify it to one of the following: lower case letter, upper case letter, digit, or non-alphanumeric character. Note: a character is a length 1 string.(a) Write a program using string methods.(b) Write a second program without string methods.Sample output (multiple executions):Enter a character: j j is a lower case letter. Enter a character: 7 7 is a digit.Enter a character: ^^ is a non-alphanumeric character.Enter a character: CC is an upper case letter.1Question 3Write a program that will read and evaluate a mathematical expression of the form oprand1 op operand2, where operand1 and operand2 are positive integers and op is an operator (that is, + * or /, for example: 24 + 65 or 276 * 2). Assume that there is a space between each operand and operator. Note: You only need to consider the following operators: + * /.Hint: Use string operations to find the operand strings and the operator symbol, use type conversion functions to convert the operands to numbers, and use some kind of if statement(s) to check which operator symbol was given and apply the corresponding operator. For example if the operator symbol is the + character, the program should recognize that and add the two operand numbers.Sample output (multiple executions):Enter a mathematical expression: 5 + 105 + 10 = 15Enter a mathematical expression: 81 / 981 / 9 = 9Question 4Write a program that reads in an English word and prints how many vowels and how many consonants it contains. You may assume the letter Y is not a vowel.Sample output (multiple executions):Enter a word: GallagherGallagher has 3 vowels and 6 consonants.Enter a word: SterlingSterling has 2 vowels and 6 consonants.Question 5The ACME Widgets company has a new password policy. Passwords must be at least 8 characters long and must contain the following: At least two uppercase letters At least one lowercase letter At least two digits At least one special character: ! @ # $Write a program that reads in a string and determines whether or not it is a valid password.Sample output (multiple executions):Enter a password: P4Ssword1!P4Ssword1! is a valid password. Enter a password: password password is not a valid password.2

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CS1114-Homework 4- an expression to print the string from the middle character to the end
$25