Write a program that asks the user to enter a float number and evaluate the function f(x) as follows: x if x<0 f (x) = {x? if 0
Q: A palindromic prime is a prime number and also palindromic. For example, 131 is a prime and also a…
A: According to the Question below the Solution: Output:
Q: We can assign a value to each character in a word based on their position in the alphabet (a = 1, b…
A: Code function balanced(word) { let alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',…
Q: Write a program that will display a table of trigonometric functions: sin x, and tan x for x is from…
A: The asked C++ program has been coded by using a for loop and code for the same is given in the next…
Q: Write a program which continually asks the user for a float until a number between 10 and 12…
A: Since no programming language is mentioned , I have done the code in python. Algorithm : checkFloat…
Q: Write a program that tells what coins to give out for any amount of change from 1 cent to 99 cents.…
A: Program: //Include necessary header files #include <iostream> using namespace std;…
Q: A pedometer treats walking 2,000 steps as walking 1 mile. Write a program whose input is the number…
A: Here I have made function steps_to_miles(), which takes steps as a parameter and then convert it to…
Q: Write a program, using a function, that will check a single integer to determine if it is prime…
A: A number is said to be prime number if it has only two factors 1 and itself
Q: The following function prints the powers of 2 from 1 through n (inclusive). For example, if n is 4,…
A:
Q: We can assign a value to each character in a word based on their position in the alphabet (a = 1, b…
A: We can assign a value to each character in a word based on their position in the alphabet (a = 1, b…
Q: In Python Using the celsius_to_kelvin function as a guide, create a new function, changing the name…
A: PROGRAM STRUCTURE: Write the definition of the function to convert the celsius temperature to its…
Q: Ask the user for the coefficients a, b and c of a quadratic equation ax + bx +c = 0. Implement…
A: In this user has to input coffeicient a,b and c then calculate determinant using b*b -4*a*c then…
Q: Write a program that uses a switch statement as follows: If game contains the letter p , or P the…
A: C++ Program: #include <iostream>using namespace std; // Function print the words Play Station…
Q: Using Python to write a program that displays a square using the function DisplaySquare(n, ch). The…
A: PROGRAM CODE: def DisplaySquare(n,ch): for i in range(n): for i in range(n):…
Q: Consider the following function func for answering question: int func( int "y) { *y += 4; return…
A: x=8 total=0 total=(8/2)+func(&x) if func(&x) calls it returns 36 because we giving x…
Q: Task: Write the full program that has the following main function. Your program should ask the user…
A: Given: Program to find area or perimeter of the rectangle.
Q: Implement a fahrenheit function that returns theFahrenheit equivalent of a Celsius temperature. Use…
A: def celciusToFahrenheit(cel): #function that takes in one numeric argument representing a…
Q: This Triangle Number is produced by a pattern of dots that form a triangle. The first 5 numbers in a…
A: The above sequence or pattern can be formulated as n*(n+1)/2 for Tn term. Code in Javascript:…
Q: Consider this very simple function: def cube(x): answer = x*X*X return answer b) Show how a program…
A: Given function is, def cube(x): answer=x*x*x return answer This function returns the cube…
Q: Implement the following functions. The functions return a real number: (a) Function Celsius…
A: I have provided a solution in step2.
Q: |Write a program that prompts the user to enter the numerator and denominator of a fraction. The…
A: import java.util.*; public class fractioncheck {public static void main(String args[]) { Scanner…
Q: Write a program which prints the following message in the output screen by using In and \t…
A: Given, A program which prints the given message in the output screen by using \n and \t functions.…
Q: Suppose that you work for a beverage company. The company wants to know the optimal cost for a…
A: Code import java.util.*;public class Main{ public static void main(String[] args) { int…
Q: A prime number is a number that is only evenly divisible by itself and 1. For example, the number 5…
A: Actually, the code has given below:
Q: Consider this very simple function: def cube (x): answer = x * X*X return answer b) Show how a…
A: Given function is, def cube(x): answer=x*x*x return answer This function returns the cube…
Q: Write a function which increments a string to create a new string. • If the string ends with a…
A: const incrementString = str => { const letters = [...str].filter(x => /[a-z]/g.test(x)).join``…
Q: Write a program that prompts the user to enter an integer (n) and a sum value (s). The program…
A: Algorithm: Step1: Declare variable n. Step2: Declare variable to store sum value, difference value…
Q: Objective: A program should be developed to read the value of x. It computes the value of f(x)…
A: Read a float type value x from the user. Using if/else statement checks whether the given input…
Q: Write a program that does temperature converter", "- The user will enter if he wants the result in…
A: The following are steps needs to be taken for the given program: Asking user the temperature as…
Q: Write a program that computes the body mass index (BMI) of an individual. Your program should begin…
A: Note : Here I have asked for the height in inches and weight in pounds from user. Algorithm : Step…
Q: Write a program that finds the grade corresponding to the average mark. The program uses a function…
A: Write a program that finds the grade corresponding to the average marks. Answer: #include…
Q: . Write a c++ program that tells what coins to give out for any amount of change from 1 cent to 99…
A: Programming instructions: Declare the required variables. Use a do-while loop that allows the user…
Q: In python.... A pedometer treats walking 2,000 steps as walking 1 mile. Write a program whose input…
A: Actually, python is a easiest programming language. It is a structural and object oriented…
Q: Write a program that finds a number positive or negative. Using the function
A: Since no programming language is mentioned, I am using python Algorithm: Start Read a number n…
Q: A prime number is a number that is only evenly divisible by itself and 1. For example, the number 5…
A: #include <iostream> using namespace std;void getNumber(int &a){ cout<<"Enter a…
Q: Write a program that will display a table of trigonometric functions: sin x, and tan x for x is from…
A: SOURCE CODE: import math#read degreeprint("{:15}".format("Angle"),end=" ")print("{:10}".format("sin…
Q: The ceiling of a floating-point number x is the smallest integer that is still larger than or equal…
A: ANSWER:-
Q: Write a program that will read an executive's job number, level number, and basic pay and then…
A: #define CA1 1000#define CA2 750#define CA3 500#define CA4 250#define EA1 500#define EA2 200#define…
Q: Suppose that you work for a beverage comnpany. The company wants to know the optimal cost for a…
A: The program is written in C language.
Q: hat returns the sum of multiples of 3 and 5 between 0 and limit (parameter). For example, if…
A: Below the python code
Q: (USING MATLAB!) Write a function that will return a random number (float number). If no arguments…
A: The Matlab Program is given below:
Q: Write a program that asks for two integers and writes both the Euclidean division and the real…
A: Solution of given question :
Q: The n'h Fibonacci Number can be calculated using the following formula: و « 1+ v5 V5 1- V5 -)") 2 1…
A: Divide the formula in three parts: part1 = ((1+5)/2)n part2 = ((1-5)/2)n part3 = (part1 - part2)/5…
Q: Write a program that will: • Select a random number between 1 and 100. • Test if the number is prime…
A: Written code in Python since no programming language was mentioned - from random import *…
Q: A positive integer is entered through the keyboard. Write a function to obtain the prime factors of…
A: The prime factors of a positive integer are the prime numbers that divide that integer exactly,…
Q: Suppose that you work for a beverage company. The company wants to know the optimal cost for a…
A: PROGRAM CODE: #include <iostream> // include header file for input output…
Q: Given the center and a point on the circle, you can use this formula to find the radius of the…
A: The program contains four functions named "distance", "radius", "circumference", and "area". In main…
Q: 3) Write a program to find a. Surface area (A= 2 r n) b. volume(v=r ² a h) of a cylinder using…
A: Algorithm: Step-1: Start Step-2: Take input radius and height from the user. Step-3: Calling…
Q: Determine all the output from the following segment of the program as it would appear on the screen.…
A: Given program: #include <iostream> using namespace std; int my_function1(); void…
Q: Given the center and a point on the circle, you can use this formula to find the radius of the…
A: ALGORITHM:- 1. Take input for the coordinates of center and the point on the circumference. 2.…
Q: Write a program that prompts the user for a positive integer N>1, then calls a function called FACT…
A: Program code: //include the required packages #include <iostream> using namespace std;…
python simple code
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
- (Civil eng.) Write an assignment statement to calculate the linear expansion in a steel beam as a function of temperature increase. The formula for linear expansion, l, is as follows: l=l0(1+(TfT0)) l0isthelengthofthebeamattemperatureT0.isthecoefficientoflinearexpansion.Tfisthefinaltemperatureofthebeam.(Civil eng.) Write an assignment statement to determine the maximum bending moment, M, of a beam, given this formula: M=XW(LX)L X is the distance from the end of the beam that a weight, W, is placed. L is the length of the beam.(Civil eng.) Write a C++ program to calculate and display the maximum bending moment, M, of a beam that’s supported on both ends (see Figure 3.8). The formula is M=XW(LX)/L, where X is the distance from the end of the beam that a weight, W, is placed, and L is the beam’s length. You program should produce this display: The maximum bending moment is xxxx.xxxx The xxxx.xxxx denotes placing the calculated value in a field wide enough for four places to the right and left of the decimal point. For your program, assign the values1.2,1.3,and11.2toX,W,andL.
- Q6: The volume of oil stored in an underground 200-foot deep eylindrical tank is determined by measuring the distance from the top of the tank to the surface of the oil. Knowing this distance and the radius of the tank, the volume of oil in the tank can be determined by using this formula: volume = 7 radius (200- distance) Using this information, write a program that uses a function called volume to calculate the volume of oil in the tank.Domino's Time Function Name: dominosTime() Parameters: N/A Returns: None Description: During the summer, you ordered a lot of food from Domino's. Pizzas are $12, an order of pasta is $6, and chicken wings are $8. Write a function that asks the user how many of each food item they would like, and then print a response telling them what their order to- tal will be. The order total should be an integer. >>> dominosTime() How many pizzas do you want? 3 How many orders of pasta do you want? 2 How many orders of chicken wings do you want? 2 By ordering 3 pizzas, 2 orders of pasta, and 2 orders of chicken wings, your order total comes to $64.use C++ programming language Write a program that computes and displays the charges for a patient’s hospital stay. First, the program should ask if the patient was admitted as an inpatient or an outpatient. If the patient was an inpatient, the following data should be entered: The number of days spent in the hospital The daily rate Charges for hospital services (lab tests, etc.) Hospital medication charges If the patient was an outpatient, the following data should be entered: Charges for hospital services (lab tests, etc.) Hospital medication charges Use a single, separate function to validate that no input is less than zero. If it is, it should be reentered before being returned. Once the required data has been input and validated, the program should use two overloaded functions to calculate the total charges. One of the functions should accept arguments for the inpatient data, while the other function accepts arguments for outpatient data. Both functions should return the…
- Future Investment Value = investment amount * (1 + monthly interest)^(number of years * 12) Using this formula, write a function in Python called futureValue that prompts the user to enter an investment amount, an annual percentage interest rate, and the amount of years. The function should accept the input as arguments. The interest rate should have a default value of 7%. You can add default values of your choice for the amount of years. This function should print out a table that displays the future values. Demonstrate this function in another function called main. Format your output by two decimal places. Output Example: Enter the amount you want to invest: 1000 [Enter] Enter the interest rate for your investment: [Enter] Enter the number of years you want to invest this money: 30 [Enter] Years Future Value 1 1093.81 2 1196.41 ........ 30 14730.58In Python Text-based adventure game: Pretend you are creating a text-based adventure game. At different points in the game, you want the user to select to fight, run, or hide from certain enemies. The selection variable must be sent as an argument into the choice() function. The user should enter 1 to fight, 2 to run, or 3 to hide in the main(). The choice() function should print one of the three options. Add an if statement in the choice() function to make the correct selection.For the following code: for ( a = 1, b = 5, c = 3; a < 4; a++, b++ ) { c = a * b + c; } Indicate what values for the following variable will be when the code endsa=b=c=
- If return statement is not used inside the function, the function will return: a. None b. Null c. Arbitary value d. 0Fy F= 40N 75 mm Fx 325 mm Figure 1 F = (4/5)F and F, = /5)F Total Moment at B = F,dy + (-F,)d, Where d, and dy, are the perpendicular distance in meter. In this example it is given that d, = 175mm and dy = 325 mm. As a programmer it is your responsibility to write a code to solve for the total moment at B. The requirement to find the total moment is as follows: 1) Please write a code using object-oriented programming to solve for the total moment. (You can test your code using the data given above.) 2) Declare a class, Moment. 3) The user needs to enter the information for the d, and d,. Write a statement to ask the user on the number of data that the user want to calculate the moment with different n values of d, and dy. 4) Declare a constructor to initialize the input, decide which one of the inputs that you want to use constructor for the initialization. 5) Print the output to the screen and a datafile name TotalMoment.txtHi All, Need help with this homework question. All coding is in Python. 1.) Rectangle Area The area of a rectangle is calculated according to the following formula: Area= Width * Length Design a function that accepts a rectangle's width and length as arguments and returns the rectangle's area. Use the function in a program that prompts the user to enter the rectangle's width and length, and then displays the rectangle's area. All coding is done in Python.