Trace and write the output of the following program segments. Justify your answer. int Y= 30; if (y > 20 Il y >60 Cout<<"work hard"<=y) Cout < < "just do it"<
Q: The manager of Mama Calari’s Pizza Palace wants a program that calculates and displays the number of…
A: The manager wants to calculate the number of pizza slices into which the pizza can be divided.…
Q: The boy scouts' popcorn supplies are all over the place and troops are only receiving certain…
A: Python used to answer this question
Q: A triangle is considered valid if the sum of each 2 sides is greater than the remaining third side.…
A: We have to write a program a program that takes the length of three sides and print "equilateral",…
Q: 2) In football, a touchdown counts as 6 points, an extra point after a touchdown counts as 1 point,…
A: #include<stdio.h> int main(){ int td,s,ep,f,total; printf("Number of touchdowns: ");…
Q: 01: Draw a flowchart for work the traffic lights ? Q2: Write the algorithm required to find the…
A: Q1 flowchart is as given below :
Q: Write a program that lets the user guess whether the flip of a coin results in heads or tails. The…
A: The program has the following algorithm: Declare the necessary variables within the “main()”…
Q: Q3: Write a VB program to enter a mark of a student and then find his grade as follows: If mark >=…
A: Get input from user and convert it to integer. Chek the input with all conditions and print output…
Q: Write two scnr.nextInt statements to get input values into birthMonth and birthYear. Then write a…
A: The corrected code is given below:
Q: Assuming the following code, what will the value of x be after the code is executed: x = 20 if x %…
A: SCREENSHOT OF CODE:-
Q: 1. Write a program to find the square of two numbers 10, -4. 2. Write a program to find the square…
A: 1. Sample Response: #Python3 program#function to print teh square of 10 and -4def printSquare():…
Q: Ex: If the input of the program is: food.txt and the contents of food.txt are: Sandwiches Ham…
A: Code Screenshot :
Q: The factorial of 1 is written 1! and equals 1. Additionally, the factorial of 5 is written 5! and…
A: Please refer below for your reference: Language used is Python: def factorial(n): a=1; for i…
Q: Write two scnr.nextInt statements to get input values into birthMonth and birthYear. Then write a…
A: for input use scanner class
Q: Q3: Write a VB program to enter a mark of a student and then find his grade as follows: If mark >=75…
A: VB program is asked with the following conditions: If mark>=75 print Grade = A If…
Q: A discount of 20% will be given to any goods that is bought from GMART shop. Write a program that…
A: Here is the solution which is mentioned below : NOTE: Programming lamguage is not given, I have…
Q: An oil slick occurs when an underwater refinery pipe ruptures, pumping oil into the water. The…
A: Program: // include required header files #include <iostream> #include <iomanip>…
Q: Write a number activity and then circle the circle or square. The input will be in the form (letter…
A: Algorithm - Create a new function with name perimeter with two arguemnt. Now use the below logic…
Q: 2. Trace and write the output of the following program segments. Justify your answer. int y = 30; if…
A: Here in this question we have given a code and we have asked to trace the code and find output .
Q: odify the guessing-game program so that the user thinks of a number that the computer must guess.…
A: Given: odify the guessing-game program so that the user thinks of a number that the computer must…
Q: ': The output of the following program is for k=1:5 If (rem(k,3) #0 && floor (k/2 # k/2 && floor…
A: Here, we have to choose an option for the above question.
Q: Given a positive integer n, the following rules will always create a sequence that ends with 1,…
A: 1)Read the n value using int(input()) function 2)print n value 3)repeat while until n!=1 4)…
Q: Q3: Write a VB program to enter a mark of a student and then find his grade as If mark >=75 print…
A: Algorithm 1.create one module name is marks 2.enter student name marks 3.calculate total marks…
Q: Consider the following program: int x, y; cin >> x>> y; if(x>y) x = x-y; else if(x<y) y= y-x; else…
A: Please find the answer below :
Q: Finish the program to compute how many gallons of paint are needed to cover the given square feet of…
A: I have given the code below.
Q: Given a positive integer n, the following rules will always create a sequence that ends with 1,…
A: As per the requirement program is developed. Note: Here in the question programming language is not…
Q: z=0 i=2 x=int(input("Enter any number") while i<=n: z=z+i/i+2 print(z) i=i+1 for the above program,…
A: Code: z=0i=2x= int(input("enter any number"))#reading user input#while loopwhile i<=x:…
Q: 1. A software company sells a package that retails for $99. Quantity discounts are given according…
A: logic:- take quantity as user input. apply if else to find out discount. at last subtract…
Q: Phyton: Make a program that is useful to determine if the integers X, Y and Z, provided by the…
A:
Q: What is the output of the following code segment? int num= 20, y = 5, x; cin>>X; if (x >= 2*num)…
A: Code: #include <iostream>using namespace std;int main(){ int num= 20, y = 5, x;…
Q: In a triangle, the sum of the 1st and 2nd side must always be greater than the 3rd side. Create a…
A: logic:- read three sides. Check if it is valid or not by using if first>0 && second>0…
Q: 9. Write a program that inputs two real numbers then exchanges their values. 10. Make a program that…
A:
Q: Given a positive integer n, the following rules will always create a sequence that ends with 1,…
A: Algorithm: 1. input a number 2.Condition checking that is number must be greater than 1 3.number is…
Q: The goals scored in a soccer match may be inputted as a sequence of 1s and 2s terminated by 0. The…
A: Write a program that will find which team have more goals and then print the total goals of each…
Q: WRITE A PROGRAM TO CALCULATRE THE AREA OF A RECTANGLE OF LENGTH =5 CM AND BREADTH=8CM. CALCULATE THE…
A: Hey, thank you for your question. There are multiple subparts submitted to your question. As per our…
Q: rite a program that takes in a line of text as input, and outputs that line of text in reverse. The…
A: As there is no programming language mentioned so program is attempted in python language Start…
Q: A variable like user_num can store a value like an integer. Extend the given program as indicated.…
A: PYTHON CODE:- user_num = int(input('Enter integer:\n')) print ('You entered: ' + str(user_num))…
Q: 2. Write an algorithm (pseudocode) that inputs three positive real numbers x, y, z and outputs the…
A: Psuedo code for positive real numbers as input: input first number(X) input second number(Y) input…
Q: Accept a paragraph of text consisting of sentences that are terminated by either ‘.’ (full stop),…
A: EXPLANATION --> Firstly we will create a function to count no. of words in every sentence. Then a…
Q: Given a positive integer n, the following rules will always create a sequence that ends with 1,…
A: for whitespaces of \t use end=‘\t’ , but if you don’t want these whitespaces , you can use end=‘ ’
Q: Write two scnr.nextInt statements to get input values into birthMonth and birthYear. Then write a…
A: Given: Write two scnr.nextInt statements to get input values into birthMonth and birthYear. Then…
Q: The New Telephone Company has the following rate structure for long-distance calls: The regular…
A: Solution:
Q: The goals scored in a soccer match may be inputted as a sequence of Is and 2s terminated by 0. The…
A: Code: #include <stdio.h> int main(){ int n,c1=0,c2=0; scanf("%d",&n); while(n!=0)…
Q: An employee’s total weekly pay equals the hourly wage multiplied by the total number of regular…
A: Actually, the code has given below:
Q: The first 11 prime integers are 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, and 31. A positive integer…
A: This Program has been solved using the C language.
Q: Given the following program segment. void split (int x){ if (x == 1) cout > num; split (num) ;…
A: The program inputs an integer from the user(whose value is given 7). Split function is called by…
Q: Q2) Write a program to calculate the average of the semester. To find the average of the semester,…
A: import java.util.*;public class Main{ public static void main(String[] args) { int a=0,b=0,c,d;…
Q: def countdown (n): # what is the conditional statement that sho uld go here to achieve the printout…
A: Option-1) Given Code: When we use option-1 in given code as: def countdown(n): if…
Q: A variable like userNum can store a value like an integer. Extend the given program as indicated. 1.…
A: Given requirement, A variable like userNum can store a value like an integer. Extend the given…
Q: Write a program that requests the floating number of hours a person works in a given week and the…
A: wagePerHour=float(input("Enter hourly wage: ")); #input wage per…
Q: Write two scnr.nextInt statements to get input values into birthMonth and birthYear. Then write a…
A: According to the Question below the Solution: Output:
Trace and write the output of the following program segments. Justify your answer.
int Y= 30;
if (y > 20 Il y >60
Cout<<"work hard"<<end1;
If (y < 35 &&y <y*2)
Cout < < "Dream big"<<end1;
If (y < =y I I y >=y)
Cout < < "just do it"<<end1
Step by step
Solved in 2 steps with 1 images
- Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 10 miles, 50 miles, and 400 miles. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:print('%0.2f' % your_value) Ex: If the input is: 20.0 3.1599 the output is: 1.58 7.90 63.20 Your program must define and call the following driving_cost() function. Given input parameters driven_miles, miles_per_gallon, and dollars_per_gallon, the function returns the dollar cost to drive those miles. Ex: If the function is called with: 50 20.0 3.1599 the function returns: 7.89975 def driving_cost(driven_miles, miles_per_gallon, dollars_per_gallon) Your program should call the function three times to determine the gas cost for 10 miles, 50 miles, and 400 miles. Note: This is a lab from a previous chapter that now requires the use of a function.Write a code using C++ for the given prompt: A contractor orders, say, 30 cubic yards of premixed concrete to construct a patio that is to be, say, four inches thick. The length of the patio is to be, say, twice the width. Write a program that prompts the user to specify: The amount of premixed concrete (in cubic yards) ordered The thickness of the patio (in inches) The ratio of length and width Ex. If the ratio is 3 to 2, have the program accept a 3 then a 2. Then compute the ratio using these numbers The program then outputs: The length and width of the patio (in feet). (1 cubic yard = 27 cubic feet.) To calculate the width, you will need to: Find the total cubic feet of the concrete Divide the total cubic feet of concrete by the result of the length to width ratio multiplied by the thickness of the patio, over 12 (inches in a foot) Square root the answer To find the square root of a decimal number, include the header file cmath using the statement #include <cmath>,…4.16 In Python, Write a program whose input is two integers. Output the first integer and subsequent increments of 10 as long as the value is less than or equal to the second integer. Ex: If the input is: -15 30 the output is: -15 -5 5 15 25 Ex: If the second integer is less than the first as in: 20 5 the output is: Second integer can't be less than the first. For coding simplicity, output a space after every integer, including the last.
- Hi, I need help with the following assignment. Implement a program that reads in a year and outputs the approximate value of a Ferrari 250 GTO in that year. Use the following table that describes the estimated value of a GTO at different times since 1962. Year Value 1962-1964 $18,500 1965-1968 $6,000 1969-1971 $12,000 1972-1975 $48,000 1976-1980 $200,000 1981-1985 $650,000 1986-2012 $35,000,000 2013-2014 $52,000,000"Write a program that computes the amount of calories burned when you run. Your program should ask for the duration of the run in minutes the speed of the run in mph and the weight in pounds. Computes the amount of calories burned and prints it. The calories/minute of run burned is computed using the expression below:\n", "\n", "$$????????/??????=(???∗????ℎ?∗1.6)/200$$\n", " \n", "Use a function to compute the value of MET as presented in the table below.\n", "\n", "| Speed (mph) | MET |\n", "|--------------|---------|\n", "| 5 or less | 8.3 |\n", "| 6 | 9.8 |\n", "| 7 | 11.0 |\n", "| 8 | 11.8 |\n", "| 9 | 12.8 |\n", "| 10 | 14.5 |\n", "| 12 or more | 19.0 |\n", "\n", "For values in between use the largest MET. Test your code with the values:\n", "```\n", "150 lbs, 6.5 mph and 45 minutes ==> 594.0 calories\n", "200 lbs, 9.8 mph and 30 minutes ==> 696.0 calories\n",The following equations estimate the calories burned when exercising (source): Women: Calories = ( (Age x 0.074) — (Weight x 0.05741) + (Heart Rate x 0.4472) — 20.4022 ) x Time / 4.184 Men: Calories = ( (Age x 0.2017) + (Weight x 0.09036) + (Heart Rate x 0.6309) — 55.0969 ) x Time / 4.184 Write a program with inputs age (years), weight (pounds), heart rate (beats per minute), and time (minutes), respectively. Output calories burned for women and men. Output each floating-point value with two digits after the decimal point, which can be achieved by executingcout << fixed << setprecision(2); once before all other cout statements. Ex: If the input is: 49 155 148 60 the output is: Women: 580.94 calories Men: 891.47 calories
- 4.16 In Python, Write a program whose input is two integers. Output the first integer and subsequent increments of 10 as long as the value is less than or equal to the second integer. Ex: If the input is: -15 30 the output is: -15 -5 5 15 25 (with the end starting a new line.) Ex: If the second integer is less than the first as in: 20 5 the output is: Second integer can't be less than the first. For coding simplicity, output a space after every integer, including the last. creating a new line at the end. (ex: 5 4 3 2 1 )Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 10 miles, 50 miles, and 400 miles. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:print('{:.2f}'.format(your_value)) Ex: If the input is: 20.0 3.1599 the output is: 1.58 7.90 63.20 Your program must define and call the following driving_cost() function. Given input parameters driven_miles, miles_per_gallon, and dollars_per_gallon, the function returns the dollar cost to drive those miles. Ex: If the function is called with: 50 20.0 3.1599 the function returns: 7.89975 def driving_cost(driven_miles, miles_per_gallon, dollars_per_gallon) Your program should call the function three times to determine the gas cost for 10 miles, 50 miles, and 400 miles. Note: This is a lab from a previous chapter that now requires the use of a function. def driving_cost(driven_miles, miles_per_gallon,…Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 10 miles, 50 miles, and 400 miles. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:print('{:.2f}'.format(your_value)) Ex: If the input is: 20.0 3.1599 the output is: 1.58 7.90 63.20 Your program must define and call the following driving_cost() function. Given input parameters driven_miles, miles_per_gallon, and dollars_per_gallon, the function returns the dollar cost to drive those miles. Ex: If the function is called with: 50 20.0 3.1599 the function returns: 7.89975 def driving_cost(driven_miles, miles_per_gallon, dollars_per_gallon) Your program should call the function three times to determine the gas cost for 10 miles, 50 miles, and 400 miles. python use this in answer please # Define your function here. if __name__ == '__main__': # Type your code here.
- Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 10 miles, 50 miles, and 400 miles. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:print('{:.2f}'.format(your_value)) Ex: If the input is: 20.0 3.1599 the output is: 1.58 7.90 63.20 Your program must define and call the following driving_cost() function. Given input parameters driven_miles, miles_per_gallon, and dollars_per_gallon, the function returns the dollar cost to drive those miles. Ex: If the function is called with: 50 20.0 3.1599 the function returns: 7.89975 def driving_cost(driven_miles, miles_per_gallon, dollars_per_gallon) # Define your function here. if __name__ == '__main__': # Type your code here.Use C++ Write a program that simulates flipping a coin to make decisions. The input is how many decisions are needed, and the output is either heads or tails. Assume the input is a value greater than 0. Ex: If the input is: 3 the output is: heads tails heads For reproducibility needed for auto-grading, seed the program with a value of 2. In a real program, you would seed with the current time. In that case, every program's output would be different, which is what is desired but can't be auto-graded. Note: A common student mistake is to call srand() before each call to rand(). But seeding should only be done once, at the start of the program, after which rand() can be called any number of times. Your program must define and call the following function that returns "heads" or "tails".string HeadsOrTails()The following equations estimate the calories burned when exercising (source): Women: Calories = ( (Age x 0.074) — (Weight x 0.05741) + (Heart Rate x 0.4472) — 20.4022 ) x Time / 4.184 Men: Calories = ( (Age x 0.2017) + (Weight x 0.09036) + (Heart Rate x 0.6309) — 55.0969 ) x Time / 4.184 Write a program using inputs age (years), weight (pounds), heart rate (beats per minute), and time (minutes), respectively. Output calories burned for women and men. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:print('Men: {:.2f} calories'.format(calories_man)) Ex: If the input is: 49 155 148 60