Write a program that asks the user for a positive nonzero integer value. The program should use a loop to get the sum of all the integers from 1 up to the number entered.
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: Write a program that uses loops to collect data and calculate the average score over a number of…
A: Answer : TextWindow.Write("Enter number of students(1-10): ") nStudents = TextWindow.Read()…
Q: Write a program that will correctly lists all factors of an integer entered by the user. The user
A: Algorithm - Step 1 - Start step 2- declare a integer variable n and i , and assign i= 1 step 3- Take…
Q: Write a program that asks the user for a starting value and an ending value and then writes all the…
A: num1 = int(input("Enter starting value:")) num2 = int(input("Enter ending value:")) i = num1 while…
Q: Write a program that reads an integer between 11 and 9999 and adds all the digits in the integer,…
A: Start For 3 times Input number Find the sum of digits Print sum Stop
Q: Develop a program to ask the user to enter a number, if the user enters a positive integer, then…
A: Sample Response: //C program to ask the user to enter a number,if the user enters a positive…
Q: In C++, if the statement ( int a=5, b=2; ) is written at the beginning of the program, then the…
A: In step 2, you can see the program output. In step 3, I will give you the final anwer.
Q: In python, write a program that asks the user for a positive integer value. The program should then…
A: use two while loops here: one to validate the input and one to do the calculation. Note that I…
Q: Construct a while() loop in programming language c, which prints only the even integer numbers in…
A: while(n>=2) { if(n%2==0) { printf("%d\n",n); n=n-2;…
Q: Write a main function that performs the following: • Using a for loop, prompt the user to enter the…
A: Introduction : Here we have to write a function that performs the following - 1. Using a for loop ,…
Q: Write a C++ program that accepts five values of meters, one at a time, and converts each value…
A: do { cout<<"\nEnter value in meter: "; cin >> meter; if (meter<60) {…
Q: Write a program that will correctly lists all factors of an integer entered by the user. The user…
A: Dear Student, As no programming language is mentioned I am doing it in c++.
Q: write a program with a loop that asks the user to enter a series of negative numbers. The user…
A: logic:- iterate an infinite loop read temp if temp>0 break loop else append…
Q: Write a program that calculates the balance of a savings account at the end of a period of time. It…
A: C++ program calculates the balance of a savings account at the end of a period of time. It should…
Q: Write a program that uses aa loop to display a table of the Celcius temperatures from 0 to 30 and…
A: #include<iostream> using namespace std; int main(){ //displaying the heading cout…
Q: Write a program segment that computes 1+2+3+...+(n-1)+n, where n is a data value. Follow the loop…
A: Algo:- take value of n. use loop to iterate from 1 to n and add sum value . display first sum…
Q: In this assignment, you will design a program in which you will ask the user to enter a number and…
A: Note: Programming language is missing in the question. So we will answer this program in Python…
Q: Write a program that calculates the balance of a savings account at the end of a three- month…
A: Program code: #include <iostream> using namespace std; //…
Q: Write a program that uses a while loop to enable the user to enter any number of positive integers.…
A: According to the question below the solution: Programming language is not mention so i am using…
Q: in c# write a program that would print out Johnny's salary every year for 20 years with a 3% raise…
A: using System.IO;using System; class Program{ static void Main() { double…
Q: Write a C++ loop that will read integers from the keyboard until a negative number is entered. When…
A: C++ code: #include <iostream>using namespace std; int main() { int n; int…
Q: Using Python, write a loop that calculates the (float) sum of the following series of numbers: 50 +…
A: Steps to be followed; Set total to 0.0 Store first number of series that is 50. while loop (number…
Q: Write a procedure called print_nums(n). This procedure should take a number n as its only parameter…
A: A procedure is a series of coded instructions that tells a machine how to execute a program or…
Q: Write a program that generates a random number and asks the user to guess what the number is. If the…
A: Given: Write a program that generates a random number and asks the user to guess what the number is.…
Q: 2. Write a while loop program that accepts numbers, then identify which of the numbers entered is…
A: Given: Write a C program.
Q: Write a program that uses a while loop to do the following: Repeatedly asks the user to enter a…
A: Algorithm: Start READ num IF num !=0 small=large=num while(num!=-1): READ num IF…
Q: Write a program that will print the message “Computer Science is cool” 10 times. Use a while loop.…
A: Here in this question we have asked to write a program that will print the message “Computer…
Q: Write a program segment that computes 1+2+3+..+(n-1)+n, where n is a data value. Follow the loop…
A: PROGRAM CODE: import java.util.Scanner; public class Main { public static void main(String[]…
Q: Write a program that calculates a student's GPA. Ask the user to enter grade and also the credit…
A: Sample Response: //C++ program to calculate and print the GPA#include <iostream>using…
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: thers and John A. Knox discovered that as the value of x gets larger, the value of the expression…
A: c code is an given below : #include <stdio.h>#include <stdlib.h>#include <math.h>…
Q: Write a Python program that uses a for loop with the range function to display the integers from 5…
A: Please find the answer below :
Q: In Python, create a program that meets the following requirements: Take two integers from the…
A: Program code: #Prompt the user to enter first integer number1=int(input("Enter number 1 : "))…
Q: Write pseudo code or flow chart to find the value of 2n by using a for loop, where n is an integer…
A: according tp our guidelines we can answer only one question if you want another answer of your…
Q: Write a python program with a loop that asks the user to enter a series of positive numbers. The…
A: Given: We have to write a Python program with a loop that asks the user to enter a series of…
Q: Write a program that displays a weekly payroll report. A loop in the program should ask the user for…
A: Answer: The program has shown below- #include<iostream> #include<stdlib.h> using…
Q: Write a program that will print the message “I love computer science” 12 times. Use a while loop.…
A: #include <iostream> using namespace std; int main(){ int n=1; //initialize n to 1…
Q: Write a program to generate the numbers 4 16 36 64 100 When loop starts from 1 and ends by N. After…
A: ALGORITHM:- 1. Take the input value of N. 2. Declare a variable named count that will hold the…
Q: Write a Basic program to calculate Y value if the condition (Y <0) break the loop and Y equation as…
A: Algorithm: Start Read n value Initialize x and d to 1 Initialize y to 0 Calculate…
Q: Write a program that creates three 2-digits addition questions for the second grade students. 1. If…
A: A required C++ program is as follows, #include<iostream> #include<ctime>…
Q: Write a program that plays a simple dice game between the computer and the user. When the program…
A: Actually, program is a executable software that runs on a computer.
Q: In this assignment, you will design a program in which you will ask the user to enter a number and…
A: 1.a. The loop condition will be that while temp variable is greater than 0, loop should run.…
Q: Write a program that generates a random number and asks the user to guess what the num- ber is. If…
A: C++ Code: #include <iostream> using namespace std; int main(){ int num, guess, tries = 0;…
Q: Write a program in Python that sums a series of (positive) integers entered by the user, excluding…
A: Use a while loop to iterate and here we check whether to enter loop or not based on the input value…
Q: Write a program that uses a while loop to enable the user to enter any number of positive integers.…
A: Solution :
Q: Write a program that prints multiples of 9 in descending * order on a single line. * The program…
A: C++ Program for above : #include <iostream> using namespace std; int main() { cout…
Q: Develop a program to ask the user to enter a number, if the user enters a positive integer, then…
A: Please find the answer below :
Q: Question 1: Write a program using a loop that reads in exactly 10 integers and outputs the…
A: Answer: Code: #include <iostream>using namespace std;int main(){ //declaring array of size…
Q: Using for loop, write a program that accepts an integer from the user between 100 and 1000 andchecks…
A: Since programming language nit mentioned, using java import java.util.*; public class Main { public…
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…
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
- 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.Exercise # 2: Write a while loop that prints all positive numbers that are divisible by 10 and less than the user input value n. For example, if the user enters 100, the program shall print 10 20 30 40 50 60 70 80 90.Task 2: Multiples Write a program that asks the user for an integer n, and then prints first 10 multiples of that integer. Use a while/do...while loop. Example: Enter an integer: 2 Output: 2 x 1 = 2 2 x 2 = 4 2 х 3 %3D 6 2 x 4 = 8 2 x 5 = 10 12 2 х6 2 x 7 2 х8 14 16 2 x 9 18 2 x 10 = 20
- Factorials The factorial of n (written n!) is the product of the integers between 1 and n. Thus 4! = 1*2*3*4 = 24. By definition, 0! = 1. Factorial is not defined for negative numbers. Write a program that asks the user for a non-negative integer and computes and prints the factorial of that integer. You'll need a while loop to do most of the work-this is a lot like computing a sum, but it's a product instead. And you'll need to think about what should happen if the user enters 0. 1. 2. Now modify your program so that it checks to see if the user entered a negative number. If so, the program should print a message saying that a nonnegative number is required and ask the user the enter another number. The program should keep doing this until the user enters a nonnegative number, after which it should compute the factorial of that number. Hint: you will need another while loop before the loop that computes the factorial. You should not need to change any of the code that computes the…6. Distance Traveled The distance a vehicle travels can be calculated as follows: distance = speed time For example, if a train travels 40 miles per hour for 3 hours, the distance traveled is 120 miles. Write a program that asks the user for the speed of a vehicle (in miles per hour) and how many hours it has traveled. The program should then use a loop to display the distance the vehicle has traveled for each hour of that time period. Here is an example of the output: What is the speed of the vehicle in mph? 40 How many hours has it traveled? 3 Hour Distance Traveled 1 40 2 80 3 120 Input Validation: Do not accept a negative number for speed and do not accept any value less than 1 for time traveled.Class Exercise Write a program that asks the user to enter how many students they have. Use a for loop to iterate through each student. For each student, allow the user to enter as many scores as they want and let them know that entering -1 will indicate the end of entering scores (note: use a while loop with sentinel value). Sum all the scores for each student and display the total on the screen. For example: Student 1 Total score is 340 Student 2 Total score is 200
- ASAP IN PYTHON Write a program which uses a loop to repeatedly read numbers between 10 and 99 until the user enters "done". Once "done" is entered, print out the mean, median, minimum, and maximum. If the user enters anything other than a number or an invalid number, print an error message and skip to the next numberQ2: Write a program that reads in a series of integer numbers, and determines how many positive odd numbers are among them. Numbers are read until a negative integer is given. Use DO-Loop with EXIT statement.Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask the user for the number of years. The outer loop will iterate once for each year. The inner loop will iterate 12 times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations, the program should display the number of months, the total inches of rainfall, and the average rainfall per month for the entire period. Add additional loops to validate the input: Do not accept a number less than 1 for the number of years. Continue to prompt the user for a number until a valid number is entered. Do not accept negative numbers for the monthly rainfall. Continue to prompt the user for a number until a valid number is entered
- Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate twelve times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After alliterations, the program should display the number of months, the total inches of rainfall, and the average rainfall per month for the entire period.Python Coding-While Loops (In PyCharm Community edition) Create a while loop that SUMS up ALL the numbers given from an initial number and an ending number. Example would be : Input1 : What is the first number? 0 Input2 : What is the last number? 3 DO NOT SHOW but these are the computations inside the code : 0 + 1 + 2 + 3 = 6 This is the Output : The sum of all the number from 0 to 3, is 6 In the code you are going to use a total variable and add each additional time it runs through the loop to that total. REMEMBER the assignment from the first unit of programming where we used this formula : BUT you are going to create your own method using a while loop to emulate what formula accomplishes WITHOUT using this formula. The user will put in the first number and the last to be SUMMED - you will use the while loop to calculate all of the additions leading to the final number.Problem 2: Safe Square Root Write a program to take the square root of a number typed in by the user. Your program should use a while-loop to ensure that the number they typed in is positive. If the number is negative, you should print out a warning “The number is negative. Try again.” and re-prompt the user to take a valid input. You can get the square root of a number n with Math.sqrt(n). Make sure you don't do this until the loop is done and you know for sure you've got a positive number. Sample input and output: Enter a number > -9 The number is negative. Try again. Enter a number > 9 The square root of 9 is 3.0 Enter a number > 2 The square root of 2 is 1.4142135623730951