Function name : give_fortune()
Parameters : mood (a string), age (int), name (string), year in school (int)
Returns: a fortune (string) Description : Now that you have your magic number, the fortune teller is going to tell you your fortune! Call the magic_ball() function using the age, name, and year in school parameters given in give_fortune(). Based on the fortune teller’s mood and the magic number, you will return a fortune. If the mood is “happy” and the magic number is 2 or 3, return “You’re going to get 100 on everything!!”. If the mood is “happy” and the magic number is 1, return “You’re going to get As!”. If the mood is “upset” and the magic number is 3, return “It’ll be okay!”. If the mood is “upset” and the magic number is 1 or 2, return “It’s all up to you...”.
string give_fortune(string mood, int age, string name, int year_in_school) {
int magic_number = magic_ball(age, name, year_in_school);
if(mood.compare("happy")==0) {
if (magic_number==2 || magic_number==3) {
return "You’re going to get 100 on everything!!";
} else if(magic_number == 1) {
return "You’re going to get As!";
}
}
if(mood.compare("upset")==0) {
if (magic_number==2 || magic_number==1) {
return "It’s all up to you...";
} else if(magic_number == 3) {
return "It’ll be okay!";
}
}
return "No Result";
}
Function name : give_fortune() Parameters : mood (a string), age (int), name (string), year in school...
Python
String Product Function Name: string Multiply Parameters: sentence (str), num (int) Returns: product (int) Description: You're texting your friend when you notice that they replace many letters with numbers. Out of curiosity, you want to find the product of the numbers. Write a function that takes in a string sentence and an int num, and find the product of only the first num numbers in the sentence. If num is 0, return 0. If num > O but there...
Language: Python Function name : findwaldo Parameters : string Returns: int Description: Write a recursive function that takes in a string containing some combination of letters, numbers, and spaces, and return the starting index of the first instance of “waldo” contained in that string. If the string does not contain “waldo”, return -1. This function IS case sensitive, so “waldo” is not the same as “WALDO”. Code using string functions such as .index() and .find() that oversimplify the problem will...
Function name: quick_maths() Parameters: a number (float), a number (float), an operation (string) Returns: a float Description: You’re trying to do your math homework, and you realized that you can write a program to do all the simple operations! The five possible operations are “+”, “-”, “*”, “/”, and “%”. Based on the operation that is passed in, perform the operation on the two numerical parameters. The first parameter should always go first in the operation. Return the result of...
python
Days of the Week Function Name: days_of_the_week() Parameters: list of birthdays ( list ), year (int ) Returns: list of names ( list ) Description: You and your friends all want to celebrate your birthdays together, but you don't want to stay up late on a school night. Write a function that takes in a list of tuples formatted as (day ( int ), month ( int ), name (string)), and a year ( int ). Use Python's calendar...
Function name : contains_substring Parameters : string (string), substring (string) Returns: bool Description : If the substring is entirely contained within the string, then return True, otherwise return False. An empty substring will always return False. The substring may be longer than the string. You are not allowed to just write “if substring in string”.
Student ID: Student Name: private: string region Name; / The region's name int zip; Il The region's zip int population; Points to array of population for each year int num Years; /Number of years W Private member function to create an array of population. rray(int size) ( num Years size population- new int[size]; for (int i -0;i < size; i++) population[i]-DEFAULT POPULATION public: ll Constructor PopulationReport(string r, int z, int y) ( regionName r zip z createPopulationArray(y); J Il Please...
Write a function name ‘findNumber’ that will receive three parameters: the first one is an int one-dimensional array ‘arr’, the second one is an integer ‘n’ that represents the number of elements in the array and the third one is an integer ‘x’. Using POINTERS search the array ‘arr’ for the first occurrence of that number ‘x’. If you find the number, return the position of the number in the array; otherwise return -1. For example if the array contains...
Consider the Tollowing class declaration: class student record public: int age; string name; double gpa; }: Implement a void function that initiatizes a dynamic array of student records with the data stored in the file "university body.txt". The function has three formal parameters: the dynamic array "S db, the count, and the capacity. Open and close an ifstream inside the function. Remember, you must allocate memory for the initial size of the dynamic array using "new" inside this function. If...
Function name: crazy_scrabble Parameters : word (string), current points (int), double word score (boolean) Returns: int Description: You are playing scrabble with a friend, and you thought you knew how to calculate how many points you have, but your friend suddenly starts making up all these crazy rules. Write a function that helps keep track of how many points you have with these new rules: ●Each 'k', 'm', 'p', 'x', 'y', and 'z' earns you 7 points. ●'c' and 's'...
Write a int function that accepts as parameter the name of a candidate and return the number of votes received by the candidate. So, if the user enters Duck, the output will be 6000. Of course, if the given name does not exist, display an appropriate message. Need help with the above here is what i have so far: #include <iostream> #include <iomanip> #include <string> #include <vector> #include <map> using namespace std; // Get the details from the user for...