[4] Write a test program (main) that reads a password as a string and tests for the password validity using the above functions. A valid password has at least 8 characters including at least one uppercase letter and one symbol, and no space. The program keeps asking the user to enter the valid password as long as it is not valid. Here is a sample run: Enter a valid password (8 characters, no space, 1 symbol, 1 uppercase): anhtW Enter a valid password: 3f SA k Enter a valid password: sa %&eqw3 Enter a valid password: sfAB$#195 Valid password!
Q: is the address of the original string. The second parameter is the address of a string that is…
A: class MyGenClass{ public void test(String str1,String str2){ int n=str1.length();…
Q: You must answer the Problem in C++. (Anagrams) Write a function that checks whether two words are…
A: #include <iostream> #include <string> using namespace std; bool isAnagram(const string…
Q: estion 42: Return whether a string consists of a single letter In the function below, return True if…
A: #FUNCTION DEFINATION ACCORDING TO INFORMATIONdef is_a_single_letter(string_arg):# CHECKS IF THE…
Q: Write a function validate_date(date_string) which takes in a datestring and checks if the datestring…
A: Given The answer is given below.
Q: Computer Science For each of the obfuscated functions below, state what it does and, in no more…
A: Both the codes are written in VS code. Their functions are illustrated in the subsequent steps.
Q: syntax errors are corrected and any omitted statements are included.
A: void func(double x) { double y; y = x * x + 3 / 5; } The above function is a void type…
Q: Consider the following function: int secret(int m, int n){int temp = n;for (int i = 1; i <…
A: a. i. cout << secret(18,4) << endl; The operations involved in the above function call…
Q: Write a program in C Write a function calledsum_average()whichtakesthree input parameters (x,yand…
A: #include <stdio.h> void sum_average(float a, float b, float c, float* sum, float* average) {…
Q: 13. Write a function slope (xl, yl, x2, y2) that returns the slope of the line through the points…
A: Algorithm: Start Define 2 methods, slope() and intercept which takes x1,y1,x2,y2 as arguments…
Q: Write a C function with the following prototype: int copyFile(char *filenamel, char *filename2);…
A: #include <stdio.h>#include <stdlib.h> int copyFile(char *filename1,char *filename2){…
Q: What is wrong with the following C++ function? void Maximum(int a, int b, int& max) { if (a >…
A: Given program: void Maximum(int a, int b, int& max) { if (a > b) max = a;…
Q: In the code shown above, we defined a function that receives
A: For the following code: var uppercase_first = function ( x ) {x[0] = x[0] . toUpperCase () ; }
Q: Ask the user to enter the following statement: "I like programming in C++ because C++ is fun and…
A: #include <bits/stdc++.h> using namespace std; #define int long long int int Count(string s…
Q: Write a function called isVowel that receives one parameter as character and returns true if it is a…
A: Program: // include header files. #include <iostream> using namespace std; //function which…
Q: Write a function that has the following prototype:
A: Need to include malloc.h in the header Ask the user to input no. of rows and columns Create a…
Q: Computer Science In C++ use the following STL algorithms: reverse, rotate, and shuffle. Write…
A: #include <algorithm>#include <iostream>#include <vector>using namespace std; int…
Q: 8. Write a function biggestBuried(s), which the parameter s is a string, and the function returns…
A: A Regular Expressions (RegEx) is a special sequence of characters that uses a search pattern to find…
Q: Write a function SoftMax(Q) as seen in the photo
A: #import numpy moduleimport numpy as np#function which computes softmax function values for the given…
Q: Write the following function to check whether string s1 is a substring of string s2. The function…
A: Program: // C++ version 14#include <iostream>#include <cstring>using namespace std; //…
Q: in c programming with User-Defined Functions Swapping variables Define a function named SwapValues…
A: Output Screenshot:
Q: Consider the following function that is intended to swap the values of two integers: int main () int…
A: swap function does not work because in the swap function there is need of a temporary variable who…
Q: A company wants to transmit data over the telephone but is concerned that its phones may b tapped.…
A: Note: As you have not mentioned any programming language, I am writing the program in C++.…
Q: Write a function to replace all instances of character c1 with character c2 and vice versa. Examples…
A: function doubleSwap(str, c1, c2) { let newstr = ''; for (let i = 0; i < str.length; i++){ if…
Q: Question b Write a function MyType Test that takes one argument, arg. Use exceptions to test if that…
A: Here , I have used Python exception Handling to make your code logic work. You can check the code…
Q: Write a function that counts and returns the number of vowels in the string. (For the purposes of…
A: The main objective of the c++ program, main. cpp is to prompt the user to enter the menu choice. The…
Q: 13. Let the function fun be defined as int fun (int*k) { *k +- 4; return 3 * (*k) - 1; Suppose fun…
A: According to the Question below the Solution:
Q: Write a c++ program that takes a date in the following format: December 24th, 2021 and extracts the…
A: Actually, program is an executable software that runs on a computer.
Q: Write a function with the following header to format a positive integer with the specified width:…
A: Program approach:- Import a package to get the standard I/O. Define a class. Define the main…
Q: Consider the function definition: void Demo (int intVal, float& floatVal ) { intVal = intVal…
A: Actually, function is a group of statements.
Q: function compute_stats, such that given a string of grades as an input parameter, it calls the…
A: Code: def get_new_grades(x): res=0 for i in x: res+=i return…
Q: Write a function that takes two integers and returns True if the integers have a common divisor that…
A: Required: Write a function that takes two integers and returns True if the integers havea common…
Q: 3. Write and test a function getDigits(s) that returns a string of all digits found in s (in the…
A: In this question we have to code and implement to python function which will extract the digits…
Q: Q9/Write a program with c++ that inputs a three-digit integer, separates the integer into its…
A: As you have not mentioned the programming language the following code is in c++ programming language…
Q: David is used to doing programming in Python and since the print() function in Python by default…
A: in PHP, \r\n can be used to print newline.
Q: Write a function that takes two integers and returns True if the integers have a common divisor that…
A: Required: Write a function that takes two integers and returns True if the integers havea common…
Q: Write an anonymous function which square its argument.
A: As per our company guideline we are suppose to answer only one question. Kindly repost another…
Q: Define a function named check_game_finished (encrypted_list) which takes a list of characters as a…
A:
Q: b. Write a function, called GCD that receives two parameters n, d, and prints their greatest common…
A: Code :
Q: Write a function that displays all the numbers between two integers in n lines, that are divisible…
A: Programs: The general purpose of the program is to solve complex problems and establishing the…
Q: In C, write a function that gets two ints a and b. If a>b the function returns a^3 + b^2, and…
A: /* C program to write a function that gets two ints a and b. If a>b the function returns a^3 +…
Q: Write a Python function, namely PasswordVerfication(pwdList), which takes a list of passwords. The…
A: Python Code for Above : #validity of each password def isValid( str ): lowercase, uppercase,…
Q: Consider the following function that is intended to swap the values of two integers: int main () {…
A: In step 2, you will get the explanation. In step 3, you will get the rewritten function along with…
Q: Write a function that takes a C-string as a parameter and reverses the string. The function will use…
A: 1. To reverse a string a. declare i set to 0 b. declare j set to length of string - 1 c.…
Step by step
Solved in 3 steps with 2 images
- 7. Write a function password_check() that takes as input two stringsnewpassword and oldpassword, and that accepts the new password (i.e., returnsTrue) if newpassword is different from oldpassword and newpassword is atleast 6 letters long. If the new password fails the check, your functions should returnFalse.>>> password_check('E10-s2ff', 'E10.s2ff')True>>> password_check('E10sf', 'E10.s2ff')False>>> password_check('E10-s2ff', 'E10-s2ff')False(Extra Credit) For extra credit, extend your password function so that it also checks thatthe new password contains a digit.>>> password_check('E10-s2ff', 'E10.s2ff') True>>> password_check('Eej-sdff', 'E10.s2ff')FalseMc2. WRITE PYTHON FUNCTION THAT: You need to write the function which takes the index of the last point in the path sent, current, as well as the path, as arguments and returns the index of the next point to send. To write this function, remember the equations for the slope (m) of a line given two points on the line, and the offset (c) of a line give one point and the slope: y = mx +c. If you know the slope and offset, then whenever you are given a point (x1,y1) you can determine whether it lies on the line or not by evaluating r = y1-m*x1-c. This (y=mx+c) will be zero for a point on the line, and non-zero otherwise! The easiest way to see if you are on a straight line is to use the first two points to calculate m and c, then sum the value of r for the third, fourth, etc. until you reach a point where the sum of r exceeds some threshold value. That is, when the points have accumulated too much error from a straight line. You can use 0.1 as your default value of the threshold.…uestion 42: Return whether a string consists of a single letter In the function below, return True if the input string parameter consists of a single uppercase letter; otherwise, return False. Most solutions would do this in two logical steps: first testing if the string consists of a single character and, second, testing whether that character is one of the uppercase letters (which can be done by seeing if it is alphabetically between A and Z, inclusive).
- Computer Science For each of the obfuscated functions below, state what it does and, in no more than three sentences, explain how it works. Assume that any requisite libraries have been included (elsewhere). You’re welcome to copy/paste the code into VS Code in order to style and experiment with it. int f(float x){return(int)(x+0.5);} int f(char *s){char*t=s;while(*t!='\0'){t++;}return t-s;}3. Write a function that uses regular expressions to extract SIN numbers with either dashes or spaces between the numbers, but not any other characters. E.g. the string 'My SINs are 123-456-798 and 987 654 321, and 987/432/321' should return the list ['123-456-798', '987 654 321']In Python, write a function named cipher that takes a string. The function returns that string in a ciphered form by using the ord of the first letter of the string to cipher each letter including the first letter. Hence for abc, use the ord of 'a', and add it to the ord of 'a' and convert that result to a character use the chr function. This character should be concatenated to the same action on the letter b and so on. Hence the function returns: chr(ord('a')+ord('a')) + chr(ord('a')+ord('b')) + chr(ord('a')+ord('c')).Obviously you need a loop to iterate on each letter. Write another function to decipher (do the opposite of the previous function), given a string and returns the deciphered string. Obviously, the first letter's ord is halved to find the first letter, and that value is used to decipher the remaining letters. From main, write code to get a string, as input, then call the cipher function and print its output.Then call the decipher function and display its output. The…
- Write a function called isVowel that receives one parameter as character and returns true ifit is a vowel (A, E, I, O, U) letter. Write another function called replaceV that receives two parameters as string(parameter1) and character (parameter2) and returns a new string that replaces all the vowel letters fromparameter1 with parameter2. The replaceV function should use isVowel function to check each character inthe string.Write a test program that reads a string and a character and uses replaceV to get the new string then displaysthe new string. Here is a sample run:Enter a String: Hello world!Enter a character: $The new string is: H$ll$ w$rld!12. John is used to doing programming in Python and since the print() function in Python by default prints a newline after printing the string passed to the print() function. But in his current project, he is using PHP programming language and the echo function does not print a newline by default after the end of the string. So, he often misses giving a newline after printing a message. Help David by writing a function myecho() that takes a string as a parameter and also prints a newline after printing the string.Write a C++ program for the following In this task, your job is to create a function Swapper() that takes three arguments num1,num2, and difference. The first argument should be passed by pointer, second argumentshould be passed by reference, and third argument should be passed by value. YourSwapper function should first swap the values of num1 and num2 with each other, andthen compute the difference of most significant digits of both numbers. You have to storethe difference result in difference variable. In the end, you need to display the values ofall three variables inside your Swapper method as well as in your main function.Note: You are not allowed to create any other variable or pointer inside your Swappermethod.
- 1. Write a function which takes one parameter int num, and prints out a countdown timer with minutes and seconds separated by a colon (:). It should print out one line for each second elapsed and then pause one second before printing out the next line. A few things to note: - You can assume that calling the function usleep(1000000) makes the program pause for one second - It should count down from num minutes:zero seconds to zero minutes:zero seconds - Your function must have the following signature: void timer(int num) You do not need to demonstrate calling this function from main(). You don't need to format the output nicely; the below is acceptable output for calling this function when minutes is 10: 10:0 9:59 9:58 … 9:1 9:0 8:59 8:58 … 0:2 0:1 0:0Write a function that counts and returns the number of vowels in the string. (For the purposes of this exercise, we are talking about the standard 5 vowels -- A, E, I, O, U). Write a function that counts and returns the number of consonants in the string. Write a function that converts the string to all lowercase. Write a function that converts the string to all uppercase. Write the following functions. Each of these functions should have a single parameter -- accepting a c-style string as an argument. The function should only do what is specified (note that none of these functions do any output to the screen). Your functions should use const in the prototype wherever it is appropriate: Write the main function that offers a menu and allows the user to test the functions you have implemented. Program C++, must use c- styleWrite a c++ program that takes a date in the following format: December 24th, 2021 and extracts the day, month, and year as 3 integers. Do not use string stream. Use a beginner level code. Your program should have the following functions: (a) WriteafunctiongetDatethatpromptsausertoenteradateasastringandreturns it. (b) Write a function extract that takes as its parameter a date and returns the day, month, and year as 3 integers.use the function isdigit(c) that returns true if c is a digit character and false if otherwise. (c) Write a function convertDigits that takes as its parameter a string of digits and converts it to an int.(to convert a digit character to a digit number use static_cast<Int> ('D') - static_cast<Int>('0') where d is 0,1,...,9) (d) Write a function convertMonths that takes as its parameter a month as a string and returns a corresponding number from 1 to 12 (1 for January, . . . , 12 for Decem- ber).