Write a complete program for the following problem: a. Function findNum() receives a variable named num. Identify whether the number is odd or even and display the output EVEN NUMBER or ODD NUMBER. b. Function calPetrol() receives the amount of petrol in litres. Calculate and return the price that needs to be paid if 1 litre of petrol costs RM2.85.
Q: Write a python program that takes in name and pay rate and the number of hours worked in a week by…
A: Algorithm : main function() Step 1 : setting number of persons(3) to a variable. Step 2 : declaring…
Q: Write and test the following average () function that returns the average of up to three negative…
A: NOTE: As no language is mentioned, the code is written in C++. #include <iostream> using…
Q: "Write a program that computes the amount of calories burned when you run. Your program should ask…
A: Python Code provided in next step
Q: Write a function number_of_pennies() that returns the total number of pennies given a number of…
A: Total number of pennies = number of dollars * 100 + pennies
Q: The correct prototype for the following function heading is void F1 (int &p1, double &p2, bool &p3)
A: Function prototype: A function prototype can be defined as a way to state a function that only…
Q: One lap around a standard high-school running track is exactly 0.25 miles. Write a program that…
A: Programming instruction: Declaring variable. Take input from the user. Call the function which…
Q: Write a program to gauge the rate of an employee’s raise from the previous year. The program asks…
A: Problem statement: Define hike() that computes and returns the hike percentage It estimates the…
Q: Write a program that outputs inflation rates for two successive years and whether the inflation is…
A: Program code: //include the required header files #include <iostream> using namespace std;…
Q: Consider the following function: int test(int x, int y) { if (x == y)…
A: answer is
Q: Write a program whose input is a character and a string, and whose output indicates the number of…
A: The C++ program to count the appearance of a character present in a string by using a user-defined…
Q: Write a program that outputs inflation rates for two successive years and whether the inflation is…
A: #include<iostream>using namespace std;int set(); //a function to get the…
Q: Q4: the volume of a cylinder is given by the formula: V=r r2L Where r is the cylinder's radius and L…
A: ALGORITHM:- 1. Take input for radius and length of cylinder. 2. Assign value of π using the sin()…
Q: Write a program with total change amount as an integer input that outputs the change using the…
A: Here I have created the function named exact_change(). Inside the function, I have first of all…
Q: fun_x(13,2), the return value of the * function would be 1 float fun_x (int t, int x=10) 2 3 return…
A: 1. f(13,2) return 13/2 = 6.5 But both t and x are integers. So, the result will be 6. Correct…
Q: "Write a program that computes the amount of calories burned when you run. Your program should ask…
A: Answer: Here not a talk about any particular programming language so we will do in C++ programming…
Q: 2. Write a program that accepts the price of a meal and the tip percent as a whole number. The…
A: read sale price of meal read tip percent calculate tip amount=sale price*tip/100 display sale amount…
Q: Write a program that takes hours and minutes as input and outputs the total number of minutes (1…
A: CODE:- #include <stdio.h>int hrs; int mins; int tot_mins; const int HOUR =…
Q: Write a function, add_it_up(), that takes a single integer as input and returns the sum of the…
A: I give the code in python along with output and code screenshots refer it
Q: Write a function print_sqare() which • takes 2 integers, x and y as parameters • prints the sum of…
A: By accepting x and y values, we have to print x2 , y2 and x2+y2 inside the function
Q: Complete the function given below which takes an integer parameter which is the age of a person and…
A: Start Input age Call function Print result Stop
Q: Write a program that outputs inflation rates for two successive years and whether the inflation is…
A: Since no programming language is mentioned, I am using python Algorithm: Start Implement a method…
Q: Write a function to compute the following: i.e. the area cle as given below. No need to run the…
A: Introduction: Below the java program that displays the area and perimeter of a circle that has a…
Q: A weight in pounds can be converted to an equivalent weight in kilograms. Write a function that…
A: The program is written in C language. Please check the source code in the next step.
Q: Write a function that returns the power of 2 (x) of a given number, keep asking the user to enter…
A: Please find the answer below :
Q: Write a program that outputs inflation rates for two successive years and whether the inflation is…
A: Below I have provided C++ Programming. Also, I have attached the screenshot of the code and output…
Q: coin type per line. The coin types are dollars, quarters, dimes, nickels, and pennies. Use singular…
A: Lets see the solution.
Q: Write a program, using a function, that will check a single integer to determine if it is prime…
A: As you have not mentioned the programming language in the question, so we have answered this…
Q: Given the following functions: void increment(int x, int y) { X+=y; } int main() { int n=10, amount…
A: Given:
Q: Write a program with total change amount as an integer input that outputs the change using the…
A: PROGRAM CODE:…
Q: Write a function input_names that takes as an argument a number player (supposedly valid)…
A: CODE - name=[] #take input list that will be used to print…
Q: Implement the following functions. The functions return a real number: (a) Function Celsius…
A: I have provided a solution in step2.
Q: In Python, ask user to enter a string, Hello World, then ask user to enter a single character, e.…
A: Define myFunction() to print the index and occurrence count of character in string. Input a string…
Q: Write a program that takes as input your gross salary and your total saving and uses another…
A: import java.util.*; public class Main{ public static void main(String[] args) {…
Q: rite a function days_in_month() that returns the number of days in a month. The function has the…
A: #include<stdio.h>int days_in_month(int month,int is_leap){ int res=-1; switch(month){…
Q: Write a function averageDigits that computes the average of the digits of a 3-digit positive number…
A: Here is the c++ program. see below steps.
Q: Write a program that outputs the inflation rates for two successive years and whether the inflation…
A: Include header file <iostream> for input output operation. define function getInput to take…
Q: Write a function averageDigits that computes the average of the digits of a 3-digit positive number…
A: The function averageDigits() takes an integer parameter and returns the average of all digits that…
Q: Write a function number_of_pennies() that returns the total number of pennies given a number of…
A: In Python, a function is a gathering of related statements that plays out a particular errand. It…
Q: Write a program with total change amount as an integer input that outputs the change using the…
A: Code : # definition of the exact_change() method...def exact_change(user_total): # fetch the…
Q: Write a function compute_manhattan_distance(x1,x2,y1,y2) that computes the Manhattan distance…
A: First, we will enter both the coordinates. Then we will pass these coordinates to function…
Q: Write a program whose inputs are three integers, and whose outputs are the largest of the three…
A: Please find the answer below :
Q: Write and test the following average () function that returns the average of up to three negative…
A: In this program I have created two functions First is an average function which will take three…
Q: Using the starter code below, write a program that asks a user for two points (x1, y1) and (x2, y2),…
A: We will input the (x,y) pairs for the center point and the perimeter point. Then we will pass all…
Q: Write a program that will read the value of integer x and evaluate the following function:
A: Input value of x If x>0, assign y=1 If x=0, assign y=0 If x<0, assign y=-1 Print y
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: A weight in pounds can be converted to an equivalent weight in kilograms. Write a function that…
A: The C code is given below with code and output screenshots
Q: The coding language is python and the code written was provided to us
A: A Python program that contains a function “number_of_pennies()” is as follows, File name: “main.py”…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
- Write a function number_of_pennies() that returns the total number of pennies given a number of dollars and (optionally) a number of pennies.input: 5 6 4 Output: 506 400 My Code: def number_of_pennies(dollars=0, pennies=0): numer_of_pennies = (dollars * 100) + pennies return number_of_pennies print(number_of_pennies(int(input()), int(input()))) # Both dollars and penniesprint(number_of_pennies(int(input()))) # Dollars only However, this is the output that I am getting: <function number_of_pennies at 0x7f6a5e1d7e50> <function number_of_pennies at 0x7f6a5e1d7e50>Please post answer in Coral One lap around a standard high-school running track is exactly 0.25 miles. Write a program that takes a number of miles as input, and outputs the number of laps. Ex: If the input is 1.5, the output is: 6.0 Ex: If the input is 2.2, the output is: 8.8 Your program should define and call a function: Function MilesToLaps(float userMiles) returns float userLapsWrite a function days_in_month() that returns the number of days in a month. The function has the following prototype: int days_in_month(int month, int is_leap); Month should be an integer value between 1 and 12. The function should return (-1) if an invalid month is input. The variable ‘is_leap’ is 1 for leap years, 0 otherwise.
- Write a function NumberOfPennies() that returns the total number of pennies given a number of dollars and (optionally) a number of pennies. Ex: 5 dollars and 6 pennies returns 506. #include <iostream>using namespace std; /* Your solution goes here */ int main() { cout << NumberOfPennies(5, 6) << endl; // Should print 506 cout << NumberOfPennies(4) << endl; // Should print 400 return 0;}Write a function NumberOfPennies() that returns the total number of pennies given a number of dollars and (optionally) a number of pennies. Ex: 5 dollars and 6 pennies returns 506. #include <iostream>using namespace std; void NumberOfPennies(int NumberOfDollars, int NumberOfPennies){if (NumberOfDollars == 1) {NumberOfDollars = NumberOfPennies * 100;}}/* Your solution goes here */ int main() {cout << NumberOfPennies(5, 6) << endl; // Should print 506cout << NumberOfPennies(4) << endl; // Should print 400return 0;} Please help me with this problem using c++.Define function print_popcorn_time() with parameter bag_ounces. If bag_ounces is less than 3, print "Too small". If greater than 10, print "Too large". Otherwise, compute and print 6 * bag_ounces followed by "seconds". End with a newline. Remember that print() automatically adds a newline.
- Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the three values. Ex: If the input is: 7 15 3 the output is: largest: 15 smallest: 3 Your program must define and call the following two functions. The function largest_number() should return the largest number of the three input values. The function smallest_number() should return the smallest number of the three input values. largest_number(num1, num2, num3)smallest_number(num1, num2, num3) Note: DO NOT use max() and min().Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the three values. Ex: If the input is: 7 15 3 the output is: largest: 15 smallest: 3 Your program must define and call the following two functions. The function largest_number() should return the largest number of the three input values. The function smallest_number() should return the smallest number of the three input values. largest_number(num1, num2, num3)smallest_number(num1, num2, num3) Note: DO NOT use max() and min(). python please explain so i understand def largest_number(num1, num2, num3): # Type your code here. def smallest_number(num1, num2, num3): # Type your code here. if __name__ == '__main__': # Type your code here.Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the three values. Ex: If the input is: 7 15 3 the output is: largest: 15 smallest: 3 Your program must define and call the following two functions. The function largest_number() should return the largest number of the three input values. The function smallest_number() should return the smallest number of the three input values. largest_number(num1, num2, num3)smallest_number(num1, num2, num3) Note: DO NOT use max() and min(). python please explain so i understand def largest_number(num1, num2, num3): # Type your code here. def smallest_number(num1, num2, num3): # Type your code here. if __name__ == '__main__': # Type your code here. this is what i did def largest_number(num1, num2, num3): if(num1>num2 and num1>num3): return num1 elif(num2>num1 and num2>num3): return num2 else: return num3…
- Change this question to work using a function. decide what the name of the function of each should be, how many parameters are required and what value needs to be returned. You're no longer required to solve the problem - try to re-manage your code to be a function. write a program which prompts the user for a Celsius temperature, convert the temperature to Fahrenheit, and print out the converted temperature. c = float (input ("What is the temperature in Celsius? '")) f = c* (9/5)+32 print ("The temperature in Fahrenheit is:”,f)Question 2: Write a Python function called weighted average (), which reads four variables from the keyboard and displays a message with the weighted average. The input variables are: the first note, followed by its weight, and the second note, followed by its weight.The 4 variables given as input are real numbers, and the displayed result is a real number.Define a function print_feet_inch_short(), with parameters num_feet and num_inches, that prints using ' and " shorthand. End with a newline. Remember that print() outputs a newline by default. Ex: print_feet_inch_short(5, 8) prints:5' 8" Hint: Use \" to print a double quote. ''' Your solution goes here ''' user_feet = int(input())user_inches = int(input()) print_feet_inch_short(user_feet, user_inches) # Will be run with (5, 8), then (4, 11)