Write the function parrotTrouble. *
Q: Write a program in python that prints a pyramid made of letters in the middle of the screen. Use…
A: #function to print pyramind as requirement def print_pyramind(c): #Defining string to print…
Q: ghci> take 5 fakePrimes [121,143,169,187,209] If needed, you can define additional supporting…
A: Normally prime numbers nothing but the numbers which are divisible by 1 and itself. Then we will…
Q: write a program that simulates coin tossing. for each toss of the coin the program should print…
A: For simulating tossing of a coin using java program, following steps can be followed: Import the…
Q: 2, What is the computational complexity of the following function? // findprimes // This function…
A:
Q: Write a program in C++ with total change amount as an integer input that outputs the change using…
A: A C++ program for the given criteria is as follows, File name: “main.cpp” #include <iostream>…
Q: Write a function that implements a simple calculator. It inputs 3 values, two numbers and an integer…
A: The above question is solved in step 2 :-
Q: Here is a function prototype: int getTotal(int, double, string); Which of these prototypes would…
A: Method Overloading is a feature that allows a class to have more than one method having the same…
Q: Implement a function priceTShirt in Python that computes and returns the price of a T-shirt. The…
A: Python code for the given question :- def priceTshirt(size, slogan): price = 0 # add base…
Q: .Write a function: int calculate(int x); In java, the function returns value of 3*x^3 + 3*x^2 - 2.
A: import java.util.*;public class Main{ public static void main(String[] args) {…
Q: Illustrating your answer using the buggy code below, explain in your own words what it means for…
A: A variable is said to be local when it's declared within body of method.
Q: Write a function in Java that implements the following logic: We are having a party with amounts of…
A: As per the requirement code is written. Algorithm: Step 1: Write the main() method Step 2: Take the…
Q: Write in Java: Write a program that takes in a positive integer as input, and outputs a string of…
A: Programming Approach: Importing necessary package Declaring main class Defining the main method…
Q: Write a c++ program that takes a date in the following format: December 24th, 2021 and extracts the…
A: The code for c++
Q: Can not use "and" or "or" in java Language Write the function parrotTrouble. * * We have a loud…
A: PROGRAM STRUCTURE: Import the required package. Start the definition of the public class. Write the…
Q: 2. Write a Java program to find out the greatest common divisor of two input values using a…
A: The above question is solved in step 2 :-
Q: Create a program that takes two parameters called base and expo such that b ase is not zero and…
A: Objective: This program includes a recursive function 'power' for computing the exponential value of…
Q: Function power of type real - int - real that raises a real number to an integer power. For example…
A: Function power of type real * int - real......
Q: In haskell write a function fermat :: Integer which finds Fermat's conjecture, which is all numbers…
A: According to given problem to identify or prove the case if the conjecture is true .we can say that…
Q: Given an alphabet, print all the alphabets up to and including the given alphabet. Write a…
A: I have added the output screenshots for better understanding. Example one shows the output when we…
Q: Write a standard function definition that takes 1 parameter. The parameter is a number and the…
A: Here is the complete working code below function myFunction(num) { let sum = num; for(let i =…
Q: vi) Write a function in Javascript that takes an integer n as the parameter and returns the number n…
A: I have answered this question in step 2.
Q: An integer number is said to be a perfect number if its factors, including 1 (but not the number…
A: A perfect number is a number where the value of the number itself can be obtained summing up all its…
Q: Write a c++ program that takes a date in the following format: December 24th, 2021 and extracts the…
A: The program is written in c++. Here, December 24th, 2021 and extracts the day, month, and year as 3…
Q: lllustrating your answer using the buggy code below, explain in your own words what it means for…
A: Below find the solution In the given code there are 3 variables used those are score , message1 and…
Q: Write a function in JAVA that finds and prints the sum of two numbers and the function does not take…
A: Program Plan: Define addNumbers() function that takes input two numbers, add them and print the…
Q: Write a function in python code for checking the speed of drivers. This function should have one…
A: Python program to test the speed of the vehicle with the below conditions Speed Output Below…
Q: Write a function in JAVA language that accepts three integer parameters and returns true if two or…
A: Testing the program using modular to solve this
Q: This is ML. Need help with code through SOML. And working with java (6p) Function max3 of type int…
A: CODE:- The largest of three integers. public class LargestNumberExample3 { public static void…
Q: Write a function MaxMagnitude() with two integer input parameters that returns the largest magnitude…
A: Below is the approach and the C++ program in which a function is defined with two integer…
Q: Write a function called monkey_experiment that takes in a goal string (e.g., "methinks it is like a…
A: Outputs:
Q: Write a function in Java that implements the following logic: Given a number n, return true if n is…
A: I have provided JAVA CODE along with CODE SCREENSHOT and OUTPUT SCREENSHOT---------
Q: This is a JAVA programming assignment. Program a Genetic Algorithm to find an integer number between…
A: int select (int popsize, double sumfitness,pouplation pop) { partSum=0; rand= Random*sumfitness;…
Q: function name fracpart() that returns the fractional part of any number passed to the function. For…
A: The required C++ program code is given below: #include<iostream>#include<iomanip>using…
Q: Write a C# class Factors having function static int CountOddFactors(int n) that would return count…
A: Task :- Write a C# program to count the number of odd factors for given number. C# program :-…
Q: Write in Java. Given an alphabet, print all the alphabets up to and including the given alphabet.…
A: import java.util.*;public class Main{ static void printAlphabet(char ch) {…
Q: Write a function in JAVA that finds and prints the product of two numbers and the function does not…
A: Write a function in JAVA that finds and prints the product of two numbers and the function does not…
Q: Fill in the blank in the function below such that the function takes in two Card objects and returns…
A: You need to write card_one.suit == card_two.suit where card_one and card_two are the class objects…
Q: a) Implement a function start( ) that takes as input a positive number a, rounds its logarithm base…
A: Dear Student, As no language is mentioned , I am implementing the function in c++.
Q: Write overloaded function in Java calculate() with following function definitions. void…
A: Find Your Code Below
Q: Write a function hello(firstname, lastname), which, for example, if called with hello('James,…
A: Hi. Since you have not mentioned any programming language, I will attempt this question using…
Q: Write java overloaded function calculate() with following function definitions. void calculate(int…
A: Java overloaded function is used for calculating the summation of all even numbers between x and y…
Q: TTTT Vrite a function in Java that implements the following logic: Given a number n, return true ifn…
A: Logic:- if n>=1 && n<=10 return true else if(outsideMode==true) If(n<=1 ||…
Q: Define a function in JAVA that takes three integers x, y, andt as the input parameters and the…
A: Define a function in JAVA that takes three integers x, y, and t as the input parameters and the…
Q: Write a program that asks the user to input two numbers. If the first number entered is greater than…
A: C++ Programming language: C++ is an object oriented programming language that was developed as an…
Q: Trace the function f as demonstrated in class for the function call f(3, 2): void f(int x, int y) {…
A: Here in this question we have given a c++ code segment and we have asked to trace the following code…
Q: Write a function fune/2 which has two arguments and returns true, if the two arguments are equal,…
A: Please refer below code and output screenshot: In below code fune__2 implies fune/2: Language used…
Q: write this program in C++ programming An integer number is said to be a perfect number if the sum…
A: Program: #include <iostream> using namespace std; //function declaration int IsFactor(int…
Q: Create a java program using user defined function. Create a function/method void: -showinfo with…
A: public class Main{ public static void showinfo(int A1, String FN, String LN, String MI, int A2)…
Q: 05: Consider the following Java program: public void fun(void) { int a, b, c; /* definition 1 */ ...…
A: The java program: public void fun(void) { int a, b, c; /* definition 1 */ . . . while (.…
Use java Language
Write the function parrotTrouble.
*
* We have a loud talking parrot. The "hour" parameter
* is the current hour time in the range 0..23. We are
* in trouble if the parrot is talking and the hour
* is before 7 or after 20. Return true if we are
* in trouble.
*
* Some Examples:
* parrotTrouble(true, 6) returns true
* parrotTrouble(true, 7) returns false
* parrotTrouble(false, 6) returns false
*
* @param isTalking true if the parrot is talking.
* @param hour the time of day from 0..23.
* @return true if you're in trouble with your neighbors.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
- Write just the function thrice(String a) and write it in JAVAWrite a recursive function that takes as a parameter a nonnegative integer and generates the following pattern of stars. If the nonnegative integer is 4, the pattern generated is as follows: **** *** ** * * ** *** **** Also, write a program that prompts the user to enter the number of lines in the pattern and uses the recursive function to generate the pattern. For example, specifying 4 as the number of lines generates the preceding pattern.Write a function PrintShampooInstructions(), with int parameter numCycles, and void return type. If numCycles is less than 1, print "Too few.". If more than 4, print "Too many.". Else, print "N: Lather and rinse." numCycles times, where N is the cycle number, followed by "Done.". End with a newline. Example output with input 2: 1: Lather and rinse.2: Lather and rinse.Done.Hint: Declare and use a loop variable. #include <iostream>using namespace std; /* Your solution goes here */ int main() {int userCycles; cin >> userCycles;PrintShampooInstructions(userCycles); return 0;} Please help me with this problem using c++.
- write a program that simulates coin tossing. for each toss of the coin the program should print heads or tails. let the program toss the coin , and count the number of times each side of the coin appears. print the results. the program should call a separate function flip that takes no arguments and returns 0 for tails and 1 for heads.import random.java. UtilWrite Java function that will accept two int number and will return addition of both numbers Thanks in advanceWrite a Java function that counts the number of 'x's in the string. Any 'x' that is followed by another 'x' should count double (e.g. "axxbxc" -> 4) /** * Count the number of 'x's in the string. Any 'x' that is followed by * another 'x' should count double (e.g. "axxbxc" -> 4) * * @param x a string. * @return the count of x's. */ public static int countXWithDubs(String s){ return -1; }
- Write a program in Python with a function perfectcube(n), which returns True if n is a perfect cube and returns False otherwise. Notice that this function is not printing anything, but rather returning True or False. The function must use exhaustive enumeration to check if n is a perfect cube. Use the function in a program where you ask the user for n and you print a statement like "Yes, that is a perfect cube" or "No, that number is not a perfect cube".This is a JAVA programming assignment. Program a GeneticAlgorithm to find an integer number between 0 and 31 that maximizes the function f (x) = x2.The initial procedure is given as below.• Population size: 6• Crossover probability: 100%• Mutation probability: 5%• Terminating criteria:o When your program produces an average of candidates is equal to or greater than29, then you can accept it as a terminating condition.• Fitness function:o You can use the function itself (f (x) = x2)as your fitness function.1. For the 1st generation, you need to print the process and result of selection, crossover, andmutation operation.you need to print the corresponding integer values and bits (binary values)of selection, crossover, and mutation operation. You also need to decide andprint the crossover point and the mutation point.2. From the 2nd generation, you do not have to print all results of selection, crossover,mutation operations. You can just print the result of each generation. Please provide…I). Write a program in c++ with class that will help an elementary school student learn multiplication. Use the rand function to produce two positive one-digit integers. The program should then prompt the user with a question, such as How much is 6 times 7? The student then inputs the answer. Next, the program checks the student’s answer. If it’s correct, display the message "Very good!" and ask another multiplication question. If the answer is wrong, display the message "No. Please try again." and let the student try the same question repeatedly until the student finally gets it right. A separate function should be used to generate each new question. This function should be called once when the application begins execution and each time the user answers the question correctly.
- (IN PYTHON) Problem 2 Write a function count_8s(string) that performs the following actions: Receives a single parameter called string that we expect to be a string. If we receive something that is NOT a string, raise a TypeError with the message “Non-string input received.” Uses recursion to count the number of eights in the string. Use a string of length 0 as your base case. Otherwise, determine if the first character in string is “8” or not, and call count_8s() again with the rest of the string as an argument. Returns the number of eights found in the string. NOTE: You are not to use a while or for loop in your code.Code in Python Write a function, print_integers_less_than(n), which takes an integer parameter n and prints each integer k which is at least 0 and is less than n, in ascending order. Hint: use a simple for loop. For example: Test Result print_integers_less_than(2) 0 1 print_integers_less_than(5) 0 1 2 3 4 print_integers_less_than(-3)Write a program that does two string functions: capitalize the first word of a phrase, and reverse the letters of words in odd positions within the phrase. For this program it is acceptable to let punctuation be part of the word. Write a capitalizeWords() and a reverseOddWords() method and call them in a test program. Make certain to properly handle empty phrases, phrases with one and two words, and phrases with greater than two words. For example, if the original phrase were: Learning Java is fun! Java is powerful and easy to use The capitalized version would be: Learning Java Is Fun! Java Is Powerful And Easy To Use And with reversed odd words would be: gninraeL Java sI Fun! avaJ Is lufrewoP And ysaE To esU