Write code that uses any type of loop. The code should continually ask for a user input and sums all user inputs that are divisible by 2. The loop should continue until the user enters a negative number. The code should output the sum a single time once user entry has completed. You may assume all libraries and namespaces have been previously written into the code, you are just writing everything that would go inside the main function (beyond the return 0:).
Q: 6. Write a loop that calculates the total of the following series of numbers:
A: START DECLARE y = 30 DECLARE sum = 0 FOR x = 1 to 30 SET sum = sum + (x/y) DECREMENT y by 1 PRINT…
Q: Why is the following function an infinite loop even though Value is sometimes odd within the loop?…
A: The condition of a loop is checked after executing all the instructions written inside the loop. For…
Q: Consider the following loop statement. Assume that the execution of the Keyboard.readInt() statement…
A: Integer is a whole number including zero . like .....-4, -3 -2 -1 0 , 1, 2, 3, 4 ... So, the DO…
Q: i=5; do {int x=0; i++; }while (i<5;). The body of loop will execute how may times?
A: This code will not give output as it has a syntax error here. while(i<5;)
Q: import java.util.Scanner; /** * ii. - This program allows money to be input in one currency and…
A: Algorithm to convert one currency to another currency: Step1: Declare money, convertedMoney ,…
Q: Write a program in C++ that calculates the occupancy rate for a hotel. The program should start by…
A: Step 1 : Start Step 2 : Take User input for the Number of Floors in the hotel. Step 3 : If the Total…
Q: How many times does a for loop run? A. A for loop runs a random number of times. B. The value of the…
A: How many time the for loop runs . How is lines of code in function is executed. What happen when…
Q: Write a FUNCTION that asks the user to input a string. Unless the user inputs "END" or "end", a loop…
A: Summary: In this question, we will take a string from the user and again take a string from the user…
Q: Write a for loop that uses the loop variable j and that would efficiently display the first 12…
A: Since no programming language is mentioned, I am using python Algorithm: Start Iterate through the…
Q: When does the following while loop terminate? char ch = 'D'; while ('A' (static_cast (ch) + 1);
A: Given while loop: char ch = 'D';while ('A' <= ch && ch <= 'Z') ch =…
Q: 7. Write pseudo code that will calculate a running sum. A user will enter numbers that will be added…
A: //Read an integerN = INPUT()//Variable to store running sumRUNNING_SUM = 0//Check if number is…
Q: QUESTION 10 def cube (number): for i in range (number, number): for j in range (number) : print…
A: In place of FILL THIS PART just write number*number*number Hence the answer to be filled in the box…
Q: Is a repetition control structure that allows you to efficiently write a loop that needs to execute…
A: The correct option is first option which is for-loop.
Q: Write a for loop that calculates the total of the following series of numbers: 2 3 4 30 + 1 30 29 28…
A: The Loop is given below:
Q: 0) Write a program that calculates and returns the sum of 1 to n in steps of , where n is an…
A: #note no programming language is mentioned so i was used c++ programming #include <iostream>…
Q: USE JAVA Write an application that allows a user to enter the names and birthdates of up to 10…
A: Given: USE JAVA Write an application that allows a user to enter the names and birthdates of up to…
Q: Write another program that generates another table with the same columns and decimals but by using a…
A: Answer in step2
Q: Write a program to compute the sum of the first N Fibonacci numbers, where N is an integer that is…
A: Write a program to compute the sum of the first N Fibonacci numbers, where N is an integer that is…
Q: Write a do while loop that uses the loop control variable to take on the values 0 through 10. In…
A: 1- As per the assignment requirement, print the number 0 to 10 along with multiply value 2 and 10…
Q: 1. Using a loop of your choice, read information from the console about employees in a company. Each…
A: Program:
Q: 3. What loops needs a semi colon after? a) For loop b) While loop c) Do while loop d) All of the…
A: Semicolon is a legitimate statement called null statement * that means " do nothing". Statements are…
Q: In situations where we need to execute body of the loop before testing the condition, we should use…
A: There is one situation is given, where we have to use one type of loops available in programming.…
Q: Write a program with python using random module for a (very) rudimentary shooter "game". You are the…
A: Program Algorithm-START-Step1: Import the essential modulesStep2: Define the shoot function.Step3:…
Q: What is the difference between the while loop and the do-while loop?
A: Difference between the while loop and the do-while loop:
Q: Write a program in C++ that calculates the occupancy rate for a hotel. The program should start by…
A: the answer is given below:-
Q: #include #include using namespace std; const int X1_INDEX= 1; const int X2_INDEX= 0; const int…
A: C++ program to find the square roots of quadratic equation :- #include <iostream>#include…
Q: Write the following function to display three numbers in increasing order:def…
A: PROGRAM CODE: import java.util.Scanner; public class Main { public static void main(String[]…
Q: -Write a function sumsteps2 that calculates and returns the sum of 1 to n in steps of 2, where n is…
A: here in this question we have asked to write program which take input from user and calculate the…
Q: Write a program in C++ that calculates the occupancy rate for a hotel. The program should start by…
A: Code.... #include <iostream> using namespace std; int main() { int floors = -1; while…
Q: By using Loop in c++, you are responsible to develop a Credit Limit Calculator, which will determine…
A: Find Your Code Below
Q: 4- GIVE ME EXAMPLE FOR NESTED LOOP ?
A: NOTE: As per Bartleby, if there are multiple questions available then we are allowed to solve first…
Q: Case - I: Playing with Digits Write a program which reads input integers from input file which…
A: Required: Required code with comments for explanation and screenshot of both code and output has…
Q: A for loop can contain multiple initialization actions separated by commas. True False
A: For loop is an iterative approach to execute any part of code repetitively with condition applied in…
Q: Program52.java Write a program that prompts the user for a binary number (from 3 to 8 bits) as a…
A: by bartleby guidelines i am able to do only one question.
Q: Non dynamic arrays are allocated at runtime where dynamic arrays are allocated at compile time. True…
A: Question 3: False Question 4: True
Q: :* Write *3 code snippet each in python* that contains For loop, While loop and loop recursion. Copy…
A: Python provides different ways for executing the loops. While all the ways provide similar basic…
Q: Write a program that will tell a user if their number is prime or not. Your code will need to run in…
A: A number is said to be prime number if it has factors 1 and itself A number is said to be factor if…
Q: Subject) - jcofield122e x O Lab 6: Module 6 - Repetitic x…
A: Here since programming language not mentioned using C
Q: Write a FUNCTION that asks the user to input a string. Unless the user inputs "END" or "end", a loop…
A: To find the letters and numbers in the string, we need to check the each character for the alphabets…
Q: By using while loop OR do..while loop, write a program that displays a list of groceries. Then,…
A: PROGRAM CODE: //Include header files#include <iostream>#include<iomanip>using namespace…
Q: 1. Ask the user to input values for the first and second currency (e.g. USD for dollars, EUR for…
A: here we make simple java program to currency converter:…
Q: 1) Which programming structure is best suited to a. For loop b. While loop c. If.else d. Do while…
A: "Since you have posted a question with multiple subpart, we will solve the first three subpart for…
Q: Question 1: Write a program in JAVA that displays a menu as shown in the sample run and asks user to…
A: PROGRAM EXPLANATION: Import java.util package. Create the main class and the main method. Create a…
Q: Hello, I have an assignment in the python program. Professor gives me a text like this: January.txt…
A: Python program to generate the January Bank Statement. customer’s account number, beginning balance,…
Q: 12. Write a loop of the specified type that sums up the even integers between 1 and 21. a. a while…
A: ANSWER:-
Q: What will be the value of AH after executing the following code mov al, 0F3H mov ah, 0F3H mov…
A: mov al, 0F3H ----> This instruction done al = F3 H => al = ( 11110011 )2 mov ah, 0F3H…
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 2 images
- Write a function that gets a number between 1 and 20 from the user.Return the number. (Use a while loop to make sure you get a number inthat range) Write a function that sums the first n odd numbers (1 + 3 + 5 + ...). Use nas a parameter and return the sum. Write a mainline (code outside of a function) that: calls the first function to get a number n (between 1 and 20) calls the second function to get the sum of the first n odd numbers prints the sum143The following requirments that weren't mentioned for solving the following Python Code below: The provided code for alphabet, test_dups, test_miss, and histogram. Your implementation of the has_duplicates function. A loop that outputs duplicate information for each string in test_dups. Your implementation of the missing_letters function. A loop that outputs missing letters for each string in test_miss. Write a function called missing_letters that takes a string parameter and returns a new string with all the letters of the alphabet that are not in the argument string. The letters in the returned string should be in alphabetical order. Your implementation should use a histogram from the histogram function. It should also use the global variable alphabet. It should use this global variable directly, not through an argument or a local copy. It should loop over the letters in alphabet to determine which are missing from the input parameter. The function missing_letters should…The purpose of each function should be documented? The purpose of each while-loop should be documented? The program runs def main(): totalBottles = 0 counter = 1 todayBottles = 0 totalPayout = 0 keepGoing = "y" while keepGoing.lower() == "y": totalBottles = getBottles() totalPayout = calcPayout(totalBottles) printInfo(totalBottles, totalPayout) print("Do you want to enter another week’s worth of data?") print("(Enter y or n)") keepGoing = input() def getBottles(): NBR_OF_DAYS = 7 totalBottles = 0 todayBottles = 0 counter = 1 while counter <= NBR_OF_DAYS: print(f"Enter number of bottles returned for day #{counter}:") todayBottles = int(input()) totalBottles += todayBottles counter += 1 return totalBottles def calcPayout(totalBottles): PAYOUT_PER_BOTTLE = .10 totalPayout = totalBottles * PAYOUT_PER_BOTTLE return totalPayout def printInfo(totalBottles, totalPayout):…
- JAVA CODE PLEASE Functions With No Parameters and Return Values Quiz by CodeChum Admin Create a function named banner that prints “CodyChum” with a newline. In the main function, write a program that accepts an integer input which would serve as an inclusive stopping point of a loop iteration that starts at the value of 1. If the number that loops through the range is divisible by either 2 or 3, then call the banner function, otherwise just print the number. Input 1. One line containing an integer Output First line is the integer user input. Succeeding multiple lines containing an integer or “CodyChum” 10 1 CodyChum CodyChum CodyChum 5 CodyChum 7 CodyChum CodyChum CodyChumI need to free memory before the program terminates . The function takes 2D dynamic strings function is : void cleanUp(char ** nouns, char ** verbs, char ** adjectives, char ** prepositions, char ** articles, int nounsize, int verbsize, int adjsize, int prepositionsize, int articlesize); I believe I need to use a loop and obviously the free calls but I am not sure how to write them : I just have them set up this way for now? Where should I put a loop ( if I am even right with this ) free(nouns); free(verbs); free(adjectives); free(prepositions); free(articles); free(nounsize); free(verbsize); free(adjsize); free(prepositionsize); free(articlesize);Write a function called printStars. The function receives a parameter containing an integer value. If the parameter is positive, the funciton prints (to standard output) the given number of asterisks. Otherwise the function does nothing. The function does not return a value. Thus, if printStars(8) is called, ******** (8 asterisks) will be printed. The function must not use a loop of any kind (for, while, do-while) to accomplish its job. Instead, it should examine its parameter, returning if the parameters value is not positive. If the parameter is positive, it: prints a single asterisk (and no other characters) then crecursively calls itself to print the remaining asterisks
- Write a program in Python for a (very) rudimentary shooter "game". You are the only shooter and you start with ammo of 10. The one enemy doesn't shoot back and starts with health of 5. Code a custom function named shoot that prints "Shot fired" and returns True for a hit or False for a miss. Generate a random 0 to assign False or 1 to assign True. In the main function, use a while loop that runs the shoot function until you run out of ammo, at which point you lose. Report both hits and misses (see Sample Outputs). If your shot is a hit as determined by the value returned by shoot, your code should lower the enemy's health. If you are lucky, the health of the enemy will be reduced to zero before you run out of ammo. If this happens, report the enemy's demise and use the break keyword to stop the loop. You have won.This code has a delay in the loop, during which time the user inputs will be ignored. So, please modify it and implement a solution that would trigger the needed function when there is an input. // Pin numbers written on the board itself do not correspond to Aurdino pinnumbers.Constants are defined to make using this board easierconst uint8_t BTN_PIN = 2;const uint8_t LED_PIN = 13;//assigning button;s previous state and LedSate to LOWuint8_t buttonPrevState = LOW;uint8_t ledState = LOW;//defining a new functionvoid setup(){// Assigning the types of input parameterspinMode(BTN_PIN, INPUT_PULLUP);//Assigning the types of output parameterspinMode(LED_PIN, OUTPUT);//begin of process detailsSerial.begin(9600);}void loop(){//assigning button state to be read modeuint8_t buttonState = digitalRead(BTN_PIN); //To print the following in output windowSerial.print(buttonState);Serial.print(buttonPrevState);Serial.print(ledState);Serial.println(""); //check if the button state presently is same…*in Python The built-in function eval takes a string and evaluates it using the Python interpreter. For example: >>> eval('1 + 2 * 3') 7 >>> import math >>> eval('math.sqrt(5)') 2.2360679774997898 >>> eval('type(math.pi)') <class 'float'> Write a function called eval_loop that iteratively prompts the user, takes the resulting input and evaluates it using eval, and prints the result. It should continue until the user enters 'done', and then return the value of the last expression it evaluated.
- Hello, I have an assignment in the python program. Professor gives me a text like this: January.txt 217283921200.5619.18,29.15,78.75,212.10100,20,410.29 The first line is an account number, the second line is the beginning balance, the third line is withdrawn and the last line is deposits. How can I separate every single line to read them. Can I use the loop function? Below is the assignment direction. Thank you very much ___________________________________________________________ Complete the following program: a) Read in and store the data from the file called “January.txt”. This file includes the customer’s account number, beginning balance, withdrawals, and deposits. (In that order) Note: Make sure you look at the file before you begin the project! b) Prompt the user for his/her name and age. c) Convert the customer’s name to a username that consists of the first letter of the first name, the first 5 digits of last name, and the customer’s age.(All letters should be lowercase)…Write a program with python using random module for a (very) rudimentary shooter "game". You are the only shooter and you start with ammo of 10. The one enemy doesn't shoot back and starts with health of 5. Code a custom function named shoot that prints "Shot fired" and returns True for a hit or False for a miss. Generate a random 0 to assign False or 1 to assign True. In the main function, use a while loop that runs the shoot function until you run out of ammo, at which point you lose. Report both hits and misses (see Sample Outputs). If your shot is a hit as determined by the value returned by shoot, your code should lower the enemy's health. If you are lucky, the health of the enemy will be reduced to zero before you run out of ammo. If this happens, report the enemy's demise and use the break keyword to stop the loop. You have won.Sample Output 1Shot fired. Enemy was hit!Shot fired. Shot missedShot fired. Enemy was hit!Shot fired. Enemy was hit!Shot fired. Enemy was hit!Shot fired.…Create a function get-random the parameters -count and the set -maximum and - minimum are mutually exclusive in POWERSHELL as follows: a)Write your own version of get-random that accepts all 3 of -count -min and -max as switches. It should call the standard version to produce results. Your version does not have to handle a list of values. b) The value of count should default to 1 and should have an alias of nItems. c) Write a loop to produce the requested # of items. d) Test your functions with float and integer values. e) Use the group-object cmdlet to prove that your function will generate repeats.