1. Repeatedly prompt the user to enter positives numbers. 2. Keep track of the largest even number entered by the user? Hint: How do you know if a number is even? Any number modulus two that results in a 0 is an even number. For example: 5 % 2 = 1 (odd), 4 % 2 = 0 (even), 12 %2 = 0 (even), 101%2=1 (odd) 3. When the user enters a negative number, stop and print out the largest even number entered. 4. If the user does not enter an even number, output 0 as the output. See output for coveral ovamplos lucer innut is in red)
Q: 20. or the following code if x = 2: print ('Two or more) else : print (Something else) What value of…
A: We are given a code snippet and we will compare values of x, and statements will be printed…
Q: What is the value of num when the following code snippet runs successfully? int num = 100; if…
A: According to the question below the solution:
Q: Which of the following statements are true? In each case you should justify your argument…
A: i.The condition is true. a) The condition X>Y b) Next X is assigned twice of its original value…
Q: Write a program that prompts the user to enter four integer values and prints the largest value…
A: Below I have provided Java Programming. Also, I have attached the screenshot of the code and output…
Q: What is the value of num after you run the following code snippet? int num = 100; if (num <= 100)…
A: Objective: Given some lines of code for which the output should be predicted. There are some…
Q: لغة اسمبلي 1- Write a program to read a letter in lower case then convert this letter to upper case…
A: 2.
Q: write a program that reads in an integer value between 1 and 5(inclusive) and a text word from the…
A: Code: Since you have not mentione the language to code i am providing the code in c++ #include…
Q: Write a program named TemperaturesComparison that allows a user to input five daily Fahrenheit…
A: PROGRAM: //Header package using System; //Defining class class MainClass { //Defining main()…
Q: Write a program that calculates the estimated hours and minutes for a trip given the number of miles…
A: Given: Write a program that calculates the estimated hours and minutes for a trip given the number…
Q: Write aC++program that allows a user to enter their rating of the three movies in the DarkKnight…
A: [Note: Explanation of the program code is provided within the comments.] Program code:…
Q: In [ ]: # write a program to accept a number from the user, # print "Play basketballL" if the number…
A: PROGRAM CODE: n = int(input("Enter the number: ")) // take number from the userif n<=15:…
Q: If you know the balance and the annualpercentage interest rate, you can compute the interest on the…
A: Program code: //import the required packages import java.util.Scanner; //define class…
Q: What is output by the code below? hour = 22 if hour > 12: %3D print(hour-12, "O'Clock") else:…
A: given program is hour=22if( hour>12): print(hour-12,"O'clock")else: print("10 o clock")
Q: Write an application that asks the user to enter two integers and displays “The two numbers you…
A: Question. Write an application that asks the user to enter two integers and displays “The two…
Q: In business applications, youare often asked to compute the mean and standard deviation of data. The…
A: Program Plan: input number using for loop. Use for loop to compute mean. Use another for loop to…
Q: A. Write a program that asks the user to enter a number of seconds. • There are 86400 seconds in a…
A: While doing programming in any programming language, you need to use various variables to store…
Q: Which is the correct statement in the following? O if (x = 0) cout << "x is zero"; %3D if (x < y <…
A: Here, I have to choose an option for the above question.
Q: Write program: prompt user to enter 2 double numbers which are the radius of 2 circles. Save values…
A:
Q: Write a code to check whether a given number is a perfect number Or not.
A: Actually, program is executable software that runs on a computer.
Q: Assume that the variable x is a double value. Which code keeps only 3 digits after the decimal point…
A: Given Assume that the variable x is a double value. Which code keeps only 3 digits after the decimal…
Q: Write a program that asks the user for three numbers and print the numbers in either ascending or…
A: n1 = float(input("Enter number a: "))n2 = float(input("Enter number b: "))n3 = float(input("Enter…
Q: N1, N2 and Nn print the largest number of them for example
A: a flowchart to read N numbers: N1, N2 and Nn print the largest number of them for example
Q: Write a program that asks the user to type in a time in seconds and display it in the standard…
A: Program code: //include the required header files #include<stdio.h> //define main functions…
Q: The value of a will become 3: int x = 2; x++; int a = (!5 == 5 + 2) ? 3>x ? 3: 5 : 4; cout << x;…
A: 1) In Above code segement we are using multiple conditions in Ternary Operator (?:) 2) We have two…
Q: Consider the code below. What is the output for x = 69? if x 10: print('Greater than 10') elif x >…
A: Question given - A Python code segment is given, that check a multiple if - elif - else statement…
Q: 2)write program that input three number and find the minimum number? 3)write program that input…
A: Main algorithm:- if(a<b && a<c) cout<<a<<" is minimum "; else…
Q: Ask the user to enter a name followed by a number. The program should print out the name N times,…
A: According to the Question below the Solution: Output:
Q: Which of the below Java statements finds the sum of 100, 200, 300, ..., 900, 1000? Select one: a.…
A: The code snippets given are C/C++ /Java code snippets. They can be copied to the IDE and executed to…
Q: example: 12-Hour Clock 24-Hour Clock 03:22:01 P M * 15:22:01 ** ** 4. Your solution should allow the…
A: Description: In this assignment, you need to develop a 12 hour and 24-hour time format. Apart from…
Q: Write a program named TemperaturesComparison that allows a user to input five daily Fahrenheit…
A: Write a program named TemperaturesComparison that allows a user to input five daily Fahrenheit…
Q: rite a program that asks the user to enter an integer consisting of 4 digits only, and check w many…
A: Code is given below #include <iostream>using namespace std;int main() { int num,…
Q: Write a program that will ask the user to enter 10 numbers and display the largest number entered.…
A: Note - As per our guidelines, we can provide solution only for one question. Since you have asked…
Q: randomly choose a number, accept input from the user, and print whether or not the user is correct.…
A: The answer is given below.
Q: Assuming that a user enters 9, 23, and 3 as input values one after another, separated by spaces,…
A: In step 2, you will get the answer.
Q: The picture is as far as i've gotten Sample 1: Enter numbers: 3 5 2 5 5 5 0 -------> user enters…
A: Here I have created a list to store the numbers. Next, I have used an infinite loop. Inside the…
Q: Assume that the variable x is a double value. Which code keeps only 4 digits after the decimal point…
A: Assume that the variable x is a double value.
Q: Write Psuedo-code of an algorithm that will repeatedly ask the user to enter a number 10 times. If…
A: Psuedo code is step by step written outline that can be easily translated into the program.
Q: Write a Python console application that prompts the user for a number. The application should return…
A: The asked code for the python program is given in the next step with explanatory comments.
Q: Write a program that will convert miles to kilometers and kilometers to miles. The user will…
A: Required: Required code with comments for explanation and screenshot of both code and output has…
Q: LET the user print his name and ask him as it is am or pm and print the message accordingly hi name…
A: NOTE: SINCE THE LANGUAGE OF THE PROGRAM IS NOT MENTIONED IN THE QUESTION, I HAVE USED PYTHON FOR…
Q: start Get positive integer from user, call it A. Get positive integer from user, call it B. C = A B…
A: According to me correct answer will be Option 4. A**A EXPLANATION answer of flow chart will be in…
Q: Suppose that the input is 20 -16 -5 15 6 0. What is the output of the following code? int num;int…
A: PROGRAM EXPLANATION: - Initially variable num is declared, and temp variable is declared and…
Q: Ask for and get three doubles from the user; the numbers represent the values for a, b, and c that…
A: Roots of a quadratic equation : The roots of a quadratic equation, can be calculated by using the…
Q: What is the resulting value of the following expression? 15 / 10 * 10 + 8.0 O 23 18 Error O 8.0 O…
A: In java, Arithmetic calculation is done by the Java Precedence Rule Java Precedence Rule In this…
Q: Write a program named TestsInteractive that prompts a user to enter eight test scores and displays…
A: NOTE - I have used Python programming language. Here I have created a list to store the scores.…
Q: Write a program that asks the user to enter a day (from 1 to 31), a month (from 1 to 12), and a two…
A: here in this question we have asked to write a program which take a day (from 1 to 31), a month…
Q: The following code results in an error message. What will the error message be and how can it be…
A: First error that we encountered is :- shown below :- File "<string>", line 2 return p1 + p2…
Q: Variables n, n1 and n2 are integer variables, and n1 n1 && n= n1 && n n1 and n= n1 ||n <= n2)
A: As per our guidelines we are supposed to answer only one question. Kindly repost other questions as…
Q: The code below was designed to count the number of values entered by the user using the keyboard,…
A: Given We know about the programing .
Python code easy way please
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- An integer is called squarefree if it is not divisible by any perfect squares other than 1. For instance, 42 is squarefree because its divisors are 1, 2, 3, 6, 7, 21, and 42, and none of those numbers (except 1) is a perfect square. On the other hand, 45 is not squarefree because it is divisible by 9, which is a perfect square. Write an algorithm that asks the user to enter a positive integer n and tells them if it is squarefree or not.A pentagonal number is defined as n(3n-1)/2 for n = 1, 2, …, and so on. Therefore, the first few numbers are 1, 5, 12, 22, . . . . Write a method with the following header that returns a pentagonal number: publicstaticintgetPentagonalNumber(int n) For example, getPentagonalNumber(1) returns 1 and getPentagonal- Number(2) returns 5. Write a test program that uses this method to display the first 100 pentagonal numbers with 10 numbers on each line. Use the %7d format to display each number."""This program will look for the next perfect square.Check the argument to see if it is a perfect square itself, if it is not then return -1 otherwiselook for the next perfect square.for instance if you pass 121 then the script should return the next perfect square which is 144.""" def find_next_square(sq): root = sq ** 0.5 if root.is_integer(): return (root + 1)**2 return -1 def find_next_squa2(sq): """ Alternatie method, works by evaluating anything non-zero as True (0.0001 --> True) """ root = s**0.5.
- U is upward, D is downward, L is left and R is right : Using the methods pickDir() and exractInt() as shown below, to write a simple automated game: how long does it take a robot to travel from a left line of a field to the right line? Assume field is 15 units apart (meters, kilometers, it doesn’t matter), and the robot starts on the left line. pickDir(): // return string with random direction and random distance (within maxDist) public static String pickDir (int maxDist) { Random r = new Random(); // random number generator // return direction + distance return ( "" + "LRUD".charAt( r.nextInt(4) ) + (r.nextInt(maxDist) + 1) ); } extractInt(): // returns integer from string, from pos p1 to p2: str = "D1" – extractInt(str,1,1); public static int extractInt (String str, int p1, int p2) { return ( Integer.parseInt( str.substring(p1, p2+1) ) ); } Write the main() method that keeps looping until the robot’s random left…The number of permutations of a set of n items taken r at a time is given by the following formulan!/r!(n−r)!: where n! is the factorial of n, r! is the factorial of r, and (n-r)! is the factorial of the result of n-r. The factorial of a number n can be solved using the following formula: n !=e−n nn √ 2 πn. If there are 18 people in your class and you want to divide the class into programming teams of 3 members, you can compute the number of different teams that can be arranged using this formula (n!/r!(n−r)!). When writing a C++ program that determines the number of potential team arrangements. You will need to use the double type for this computation.A nutritionist who works for a fitness club helps members by evaluating their diets. As part of her evaluation, she asks members for the number of fat grams and carbohydrate grams that they consume in a day. Then, she calculates the number of calories that result from the fat using the following formula: Calories from fat = Fat grams × 9Next, she calculates the number of calories that result from the carbohydrates using the following formula: Calories from carbs = Carbs grams × 4Create an application that will make these calculations. In the application, you should have the following methods:• FatCalories–This method should accept a number of fat grams as an argument and return the number of calories from that amount of fat.• CarbCalories–This method should accept a number of carbohydrate grams as an argument and return the number of calories from that amount of carbohydrates.
- """This program will look for the next perfect square.Check the argument to see if it is a perfect square itself, if it is not then return -1 otherwiselook for the next perfect square.for instance if you pass 121 then the script should return the next perfect square which is 144.""" def find_next_square(sq): root = sq ** 0.5 if root.is_integer(): returroot + 1)**2 return -1 def find_next_sque2(sq): """ Alternative method, works by evaluating anything non-zero as True (0.000001 --> True) """ root = sq**0.5.Build a simple guessing game where it will continuously ask the user to enter a number between 1 and 10. If the user's guesses matched, the user will score 10 points, and display the score. If the users' guess doesn’t match display the generated number. Also, if the user enters “q” then stop the game. my code till now. Please modify my code so that it works. import randomgame(num)if n=='q': def game(n): n= int(input("Enter a number between 1 and 10 ")) print("You entered:",n)r = random.randint(1,10)print("Random number is: ", r)score=0if n==r:print("You won!")print(" Your score: " ,score+10)else:print("You lost! Try again")This lotto game in the Caribbean is called super 6 where the lucky 6 numbers from 1 to 28 can allow you to win. Can you generate few lucky numbers that is likely to follow this previous number sequence 06 09 15 19 24 27
- The code I am using will not return the correct type. For example the expected answer is [1] and my code returns 1. I am at a loss for how to fix this. The code is below. def give_change(amount, coins): if amount == 0: return 0 change = [0] change2 = [] nc = 0 done = [False] * (amount+1) done [0] = True while change: nc+= 1 for v in change: for coin in coins: if coin == amount: return nc elif coin > amount: continue elif not done[coin]: done[coin]=True change2.append(coin) change, change2 = change2, [] return coins amount = (1) coins = [1,3] print(give_change(amount,coins))A regular polygon is an n-sided polygonin which all sides are of the same length and all angles have the same degree (i.e.,the polygon is both equilateral and equiangular). The formula for computing thearea of a regular polygon is given below: Write a method that returns the area of a regular polygon using the following header:public static double area(int n, double side)Write a main method that prompts the user to enter the number of sides and theside of a regular polygon and displays its area. Here is a sample run: Enter the number of sides: 5 ↵EnterEnter the side: 6.5 ↵EnterThe area of the polygon is 72.69017017488385In Java Golf scores record the number of strokes used to get the ball in the hole. The expected number of strokes varies from hole to hole and is called par (possible values: 3, 4, or 5). Each score's name is based on the actual strokes taken compared to par: "Eagle": number of strokes is two less than par "Birdie": number of strokes is one less than par "Par": number of strokes equals par "Bogey": number of strokes is one more than par Given two integers that represent the number of strokes used and par, write a program that prints the appropriate score name. Print "Error" at the end of the output if par or score is not in the expected range. If the input is: 3 4 the output is: Par 4 in 3 strokes is Birdie