This is a continuation from the previous question. Pervious question answer is float hours = sc.nextFloat(); use this for this question Now that the hours have been entered, write a loop that will run as long as the user enters bad hours data (0 or negative hours). If the user entered bad hours data, it asks them again with the message Not a valid amount of hours. Enter the hours again:
Q: write a loop that will display numbers in reverse order from 20 to 0
A: A loop is used to handle the repeat of statements. They iterate block of codes multiple number of…
Q: Below is a nested loop containing an assignment statement. How many times will the assignment…
A: The outer loop runs n times from i=1 to n
Q: How many times will the following loop execute? int num1 = 5; int num2-100; do num1-5; while (num1 -…
A: Answer: In the first question a do-while loop is given in this loop first do statement will always…
Q: Write a program that calculates the occupancy rate for a hotel. The program should start by asking…
A: Answer: Executable Code: n = int(input("Floors on the hotel: "))occupied = 0unoccupied = 0totalRooms…
Q: How many times will the following loop execute? int num1 5, num2 20; do { num1 += 2;
A: Please find the answer below :
Q: Write a program that asks the user for a positive nonzero integer value. The program should use a…
A: Java Code: import java.util.Scanner;public class Main{ public static void main(String[] args) { int…
Q: Task1. Write a nested for loop that prints the following output: 1 1 2 1 1 2 1 2 4 2 4 8 16 8 16 32…
A: Question. Answer. A nested for loop in JAVA that prints the given output is as follows:
Q: Write a program that uses a loop to ask the user for a number, then to print the first 10 multiples…
A: #include <iostream>#include<conio.h>using namespace std;int main(){ int n,i,t;…
Q: What is the output for the following java code? ... int index 0; 1; int result = while ( true ) {…
A: According to the question java is most important language in which we can use the so many things and…
Q: What do these loops print? a. int i = 0; int j- 10; while (i < j) { System.out.println(i + " " + j);…
A: While loop will repeat the block execution untill the condition in the while() is false. i++ will…
Q: How many iterations will the following loop execute? Dim intIndex As Integer = 100 Do…
A: The do...while loop executes the body at least once before checking the condition in the loop…
Q: Write a program with a loop that lets the user enter a series of integers. The user shouldenter −99…
A: Given : Write a program with a loop that lets the user enter a series of integers. The user should…
Q: Below is a nested loop containing an assignment statement. How many times will the assignment…
A: The outer loop executes n+1 times
Q: How many times is the body of the loop executed? The numbers on left are line numbers. 1 int…
A: The correct answer is given below with explanation
Q: 2) Which of the following while loops is equivalent to the below for-loop ? a. int i = 0; while (i…
A: Ans: The following while loop is equivalent to the below for loop : for (int i = 0; i < 20 ; i++)…
Q: Which of the following for loop declaration is not valid? a. for ( int i = 99; i >= 0; i / 9) b. for…
A: Option A: for (int i = 99; i >= 0; i/9) This option is invalid. The incrementation segment of the…
Q: What is the number of iterations in the following loop? int i = 1; while (i < n)!
A: while loop is a control stream explanation that permits code to be executed more than once dependent…
Q: QUESTION 1 What is i after the following for loop? int y = 0; %3D for (int i = 0; i < 10; ++i) { %3D…
A: int y=0; for(int i=0; i<10;i++){ y+=i; //y=0+1+2+3+4..... 9 } // this loop…
Q: In order to get into your secret club, someone needs to know the password! Write a program that asks…
A: I have provided PYTHON CODE along with CODE SCREENSHOT and OUTPUT SCREENSHOT------------
Q: What is the total number of iterations in the following loop ? for(int i=0; i<9; i+=2);
A: Here the loop will run from i=0 and will keep on iterating until the condition i<9 is met. The…
Q: What is the number of times the following loop is executed? for the value of b in (1,10): a printout…
A: This is basically a for loop iteration question.
Q: How many times will the loop repeat? for (int x = 5; x <= 10; x++) ( } Console.WriteLine("Hello…
A: Answer: This code is written in Csharp and we have shown in brief details explanation in the code
Q: How many times will the following loop execute? int num1 - 5; int num2 - do -100; numl-5; while…
A: 1) i) the first code will be executed for 1 time The value of num1 is 5, num1 = num1*-5 = -25.…
Q: What is the total number of iterations in the following loop ? for(int i=0; i<9; i+=2); 9.
A: The above for loop will iterate 5 times for i=0,2,4,6,8.
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 a test class that has a method to test how long it takes to count from 1 to 10000 in a loop.…
A: Program plan: Create class Test and add countTime() Method Define countTime() Method Test this…
Q: How many times will the following loop ?execute? What is the output ;int num1 = 5, num2 = 20 do }
A: Please find the answer below
Q: Based on the following code, which one is the test expression of this loop? for (x-1; x<-5; x++){…
A: Test expression The test expression is defined as the boolean conditions which are evaluated using…
Q: What is i after the following for loop? int y = 0; %3D for (int i = 0; i < 10; ++i) { %3D y += i; 0…
A: Given:-
Q: You wish to place the following code inside of a loop: x++; Which of the following loops would…
A: The Do-while loop is the loop in which test expression (loop condition) is evaluated or computed…
Q: Below is a nested loop containing an assignment statement. How many times will the assignment…
A: int z; for (int x = 1; x <= n; x++) { for (int y = 1; y <=…
Q: It then has the user enter that number of scores and computes the average.
A: n=int(input("Enter number of tests : ")) # reading number of testsi=1s=0while(i<=n):…
Q: Write a program that calculates the occupancy rate of the 120 suites (20 per floor) located on the…
A: Program code: #include <iostream> using namespace std; int main() { const int OCC = 120;…
Q: The code below is an example of what kind of loop? int x= 0; while(x<10) { x--; }
A: A loop is a programming function based on defined boundaries that iterates a statement or condition.…
Q: Write a loop that reads 100 numbers and finds the average off the number. Linux
A: Coded using Shell(Linux).
Q: How many times will the following loop run? int i = 10; do { cout << i; i=i++; } while (i < 10); .…
A: C++ programming language is an object-oriented programming language, that's used to develop web…
Q: What will the following code output? For an infinite loop, type "IL" (without the quotes). int…
A: Output of the given C++ code
Q: The for loop in (a) is converted into the while loop in (b). What is wrong? Correct it. (java…
A: Loop are used to repeatedly perform some task based on some conditions. There are various types of…
Q: Write a loop of your choice that continues to read an integer x as long as x not divisible by 5 and…
A: In this question, the coding language is not specified then we are using C++ language.
Q: Write a program that will predict the size of a population of organisms. The program should ask the…
A: PROGRAMING CODE: #include <iostream>#include <iomanip>using namespace std; int main(){…
Q: What will the following code output? For an infinite loop, type "IL" (without the quotes). int…
A: Given: Given a C++ Code, we need to give it's output.
Q: Write a program with the most appropriate loop that repeats user entered number of times (say the…
A: PROGRAM: //Importing the header file for Scanner import java.util.Scanner; //Declaring a class with…
Q: What will the following code output? For an infinite loop, type "IL" (without the quotes). int…
A: The question is to find the output of the C++ code.
Q: Write a loop in which you ask user his age, and then tell him his age. Loop should run till user wri…
A: #include <iostream> using namespace std; int main(){ int age; //Keep repeating do…
Q: Write an application that allows a user to enter the names and birthdays of up to 10 friends.…
A: Syntax: while ( Condition ) { // Loop-body } Flowchart:
Q: Write a program that calculates the equivalent resistance of a circuit. n electrical resistors with…
A: NOTE: - The program is implemented in the C language. EXPLANATION: - Integer[] of resistance to…
Q: How many times will the loop repeat? for (int x = 5; x <= 10; x++) { My Console.WriteLine("Hello…
A: 1) The C# code snippet in question does below activities It runs a for loop where loop counter…
This is a continuation from the previous question. Pervious question answer is float hours = sc.nextFloat(); use this for this question
Now that the hours have been entered, write a loop that will run as long as the user enters bad hours data (0 or negative hours). If the user entered bad hours data, it asks them again with the message Not a valid amount of hours. Enter the hours again:
Step by step
Solved in 2 steps with 1 images
- USE JAVA Write an application that allows a user to enter the names and birthdates of up to 10 friends. Continue to prompt the user for names and birthdates until the user enters the sentinel value ZZZ for a name or has entered 10 names, whichever comes first. When the user is finished entering names, produce a count of how many names were entered, and then display the names. In a loop, continuously ask the user to type one of the names and display the corresponding birthdate or "Sorry, no entry for name" if the name has not been previously entered. The loop continues until the user enters ZZZ for a name. An example of the program is shown below: Enter a name Lan Enter birthdate with slashes between the month, day, and year 12/25/1983 Enter a name or ZZZ to quit Marylouise Enter birthdate with slashes between the month, day, and year 2/20/1992 Enter a name or ZZZ to quit Arminda Enter birthdate with slashes between the month, day, and year 8/30/1992 Enter a name or ZZZ to quit Gudrun…Java Write an application that allows a user to enter the names and birthdates of up to 10 friends. Continue to prompt the user for names and birthdates until the user enters the sentinel value ZZZ for a name or has entered 10 names, whichever comes first. When the user is finished entering names, produce a count of how many names were entered, and then display the names. In a loop, continuously ask the user to type one of the names and display the corresponding birthdate or "Sorry, no entry for name" if the name has not been previously entered. The loop continues until the user enters ZZZ for a name.Write a program in Java A hotel’s occupancy rate is calculated as follows:Occupancy rate = Number of rooms occupied / Total number of rooms Write a program that calculates the occupancy rate for each floor of a hotel. The programshould start by asking for the number of floors in the hotel. A loop should then iterate oncefor each floor. During each iteration, the loop should ask the user for the number of roomson the floor and the number of them that are occupied. After all the iterations, the programshould display the number of rooms the hotel has, the number of them that are occupied,the number that are vacant, and the occupancy rate for the hotel.Input Validation: Do not accept a value less than 1 for the number of floors. Do not accepta number less than 10 for the number of rooms on a floor
- This test can only be taken once. Force Completion This test can be saved and resumed at any point until time has expired. The timer will continue to run if you leave the test. Your answers are saved automatically. • Show Timer ¥ Question Completion Status: QUESTION 1 What is the difference between a while loop and a do-while loop? O while loop checks the condition before the loop begins, whereas the do-while loop executes the body at least once before checking the condition. O while loop is used for counter-controlled and do-while, is used for a sentinel loop. O while loop is used for selection controlled and do-while is used for an infinite loop. O while loop is used for endless controlled control and do-while, is used for counter-controlled loop. Save All Ans Click Save and Submit to save and submit. Click Save All Answers to save all answers. DELLWrite a while loop which prompts the user for the name of a drink and the cost. Add these new items to the drinks_dict. When the user enters "quit", exit the loop. Be sure to cast the value for the cost to a float. Spring Water 1.25 Sparkling Water 2.00 exit Use the values() method to access the values in drinks_dict. Use a loop to print out the values. Use the keys() method to access the keys in drinks_dict. Use a loop to print out the keys. Print the code and the output from the Python Shell. Compute the sum of all of the values for the drinks. Print out the sum. Print the code and the output from the Python Shell. Write a function named find_drink_function(0 that takes two parameters a dictionary and a key: If the key is in the dictionary, return True, otherwise return False. Call the function from within main with the following arguments: drinks_dict and "Tea". Assign the returned Boolean value to a variable found. Print out the value of found. Print the code and the output from…Create a class name AddAgain for do-while loop that asks the user to enter two The numbers should be added and the sum displayed. The loop should ask the user whether he or she wishes to perform the operation again. If so, the loop should repeat; otherwise it should terminate.
- Write a loop that runs 10 times. Note: You are not required to put anything inside the loop body.Consider the code below and select all that apply: X = 0 while True: if x % 2==1: break X=X+2 print(x) a. b. C. d. e. This is an infinite loop. The iterating variable changes but it is always even. The iterating variable never changes. The loop is executed once and prints the value of x as 1. The break command is never called.Using a Sentinel Value to Control a while Loop Summary In this lab, you write a while loop that uses a sentinel value to control a loop in a Java program that has been provided. You also write the statements that make up the body of the loop. The source code file already contains the necessary variable declarations and output statements. Each theater patron enters a value from 0 to 4 indicating the number of stars the patron awards to the Guide’s featured movie of the week. The program executes continuously until the theater manager enters a negative number to quit. At the end of the program, you should display the average star rating for the movie. Instructions Ensure the file named MovieGuide.java is open. Write the while loop using a sentinel value to control the loop, and write the statements that make up the body of the loop to calculate the average star rating. Execute the program by clicking Run. Input the following: 0, 3, 4, 4, 1, 1, 2, -1 Check that the average…
- Write a program that plays a simple dice game between the computer and the user. When the program runs, a loop should repeat 5 times. Each iteration of the loop should do the following: Generate a random integer in the range of 1 through 6. This is the value of the computer’s die. Ask from user an integer in the range of 1 through 6. This is the value of the user’s die. The die with the highest value wins. (In case of a tie, there is no winner for that particular roll of the dice.) You need to validate the input if it’s correct or not. As the loop iterates, the program should keep count of the number of times the computer wins, and the number of times that the user wins. After the loop performs all of its iterations, the program should display who was the grand winner, the computer or the user.ava problem: Write an application that allows a user to enter the names and birth dates of up to 10 friends. Continue to prompt the user for names and birth-dates until the user enters the sentinel value “ZZZ” for a name or has entered 10 names, whichever comes first. When the user is finished entering names, produce a count of how many names were entered, and then display the names. In a loop, continuously ask the user to type one of the names and display the corresponding birth-date or an error message if the name has not been previously entered. The loop continues until the user enters “ZZZ” for a name.Question#2. The distance a vehicle travels can be calculated as fallout: Distance = Speed * Time For example, if a train travels 60 miles-per-hour for three hours, the distance [raveled is 120 miles. Write a program that asks for the speed of a vehicle (in miles-per-hour) and the number of hours it has traveled. It should use a loop to display the distance a vehicle has traveled for each hour of a time period specified by the user. For example, if a vehicle is traveling at 40 mph far a three-hour time period, it should display a report similar to the one chat follows: Hour Distance Traveled 1 90 2 100 3 150 Input Validation: Do not accept a negative number for speed and do not accept any value les than 1 for time traveled.