Concept explainers
Population
Write a
Input Validation: The program should not accept a number less than 2 for the starting size of the population, a negative number for average daily population increase, or a number less than 1 for the number of days they will multiply.
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Starting Out With C++: Early Objects (10th Edition)
Additional Engineering Textbook Solutions
Concepts Of Programming Languages
Starting Out with Programming Logic and Design (4th Edition)
Starting Out with Java: Early Objects (6th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
- Odd Even Number Problem Description Even Numbers are integers that are exactly divisible by 2, whereas an odd number cannot be exactly divided by 2. Example of even numbers are 2,4,6,8 and odd numbers are 1, 3, 5, 7, 9. Input The first line input contains an integer, which determines the number of test cases. Each of following lines represent sequence of integers that ends with 0. 2 34 1 8 5 22 0 10 7 16 -2 0 Output For each test case, the output will present the size of oddQueue and evenQueue following with the integers of odd and even numbers. oddQueue 2: 1 5 evenQueue 3: 34 8 22 oddQueue 1: 7 evenQueue 3: 10 16 -2 ** Your task is to write a program that will read the input and identify whether it is an odd number or even number. /******************************************************************************* Compilation: javac Queue.java** The Queue class represents a first-in-first-out (FIFO) queue of generic items.* It supports the usual enqueue and dequeue…arrow_forwardC# Programming Write a program that generates 10 random integers. Display the number only if it is more than 100 and is divisible by 2 using a while looparrow_forwardPython The month of February typically has28 days except when it is a leap year, in which case February has 29 days.Write a program that asks the user to enter a year. The program should then display the number of days in February that year. Use the following criteria to identify leap years: The program shall loop back to ask the user to enter another year. The program shall NOT display the original display message explaining what the program does If the user enters an invalid year, the program willdisplay an error message to the user and prompt for a year If the user enters 0 or hits return for the year, then the program terminatesarrow_forward
- mystery_value = 5 #You may modify the lines of code above, but don't move them!#When you Submit your code, we'll change these lines to#assign different values to the variables. #Write a program that divides mystery_value by mystery_value#and prints the result. If that operation results in an#error, divide mystery_value by (mystery_value + 5) and then#print the result. If that still fails, multiply mystery_value#by 5 and print the result. You may assume one of those three#things will work.##You may not use any conditionals.# #Add your code here!arrow_forwardSum of Numbers Problem Design a program in Python with a loop that asks the user to enter a series of positive numbers. The user should enter a negative number to signal the end of the series. After all the positive numbers have been entered, the program should display their sum.arrow_forwardHELP NEEDED ASAP! Language: JAVA Write a program that prompts the user for a value greater than 10 as an input (you should loop until the user enters a valid value) and finds the square root of that number and the square root of the result, and continues to find the square root of the result until you reach a number that is smaller than 1.01. The program should output how many times the square root operation was performed.arrow_forward
- 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.arrow_forward17. Math Tutor Write a program that can be used as a math tutor for a young student. The program should display two random numbers to be added, such as 247 +129 The program should then pause while the student works on the problem. When the student is ready to check the answer, he or she can press a key and the program will display the correct solution: 247 +129 376arrow_forwardPython programming Write a program that generates a random number and asks the user to guess what the number is. If the user's guess is higher than the random number, the program should display "Too high, try again." If the user's guess is lower than the random number, the program should display "Too low, try again." The program should use a loop that repeats until the user correctly guesses the random number. TY!arrow_forward
- 2. Class Exam Results Create a python program that allows a professor to input test results, and calculate the average and high score. The professor is not sure how many students took the exam that day, so you'll need to use a loop that iterates until the professor indicates there are no more students to enter. Include field validation logic to ensure the professor has entered valid test scores. You'll need an accumulator and counter variable to calculate the average. To determine the high, you'll need a variable that stores the current high score as you're iterating thru all the students' results. If a given student's score is higher than the current high score, that becomes the new high score. Initialize the high score to a 0 so the first student's score is automatically higher. Once the loop has ended, you've got all the information you need to print the class average, number of students and the high exam score.arrow_forwardProgramming is Javaarrow_forwardLap Timer Tool Write a Python (GUI program) that asks the user to enter the number of times that they have run around a racetrack, and then uses a loop to prompt them to enter the lap time for each of their laps. When the loop finishes, the program should display the time of their fastest lap, the time of their slowest lap, and their average lap time.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT