Concept explainers
Write a
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Starting Out with C++: Early Objects (9th Edition)
Additional Engineering Textbook Solutions
Problem Solving with C++ (9th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Absolute Java (6th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Java How To Program (Early Objects)
- The main difference between using do/while loop and while loop is that while loop executes the code block once then it checked if the condition is true so it will repeat the loop. True Falsearrow_forward2. While Loop Write a program, using a while loop, that asks the user to enter their monthly income. The program should then prompt the user to enter their expenses for the month. The program should keep a running total. Once the user has finished entering their expenses the program should then display if the user is over or under budget. • The output should display the monthly budget, the total expenses and whether the user is over or under budget. Use a empty return (enter key) to end the loop. Name the source code file yourName_labó 2.py. Test and run the program. Capture the output console and save it as an image file named yourName_labó_output6_2.jpg. • Submit the .py and the image files through Canvas. Part 1: For Loop Number Cube ----- 1. 2. 8. 27 64 125 216 343 512 729 10 1000 Part 2: notes/tips for the while loop activity Part 2: while loop Enter monthly incone: 1000 Enter your monthly expense or 0 to stop: 750 Enter your monthly expense or 0 to stop: 85 Enter your monthly…arrow_forwardIn c language, write a for loop to prompt the user to enter a number from 0 to 255. if the user enters any other number outside this range, print the number is not valid and prompt again If the user enters= 0, then exit the loop.arrow_forward
- 1. Ifthe initial condition of any while loop is false it will still execute once. 2. In the case of an infinite while loop, the while expression (that is, the loop condition) is always true. 3. A counter-controlled loop is used when the exact number of data entries is known. 4. The control variable in a flag-controlled while loop is an int variable. 5. A break statement is legal in a while loop, but not in a for loop. 6. Void methods have no return data type. 7. Ifa formal parameter is a variable of a primitive data type, then after copying the value of the actual parameter, there is no connection between the formal and actual parameter. 8. All the methods defined in a class must háve different names. 9. The statement int () list = new int[15); creates list to be an array of 14 components because array index starts at 0. 10. When you pass an array as a parameter, the base address of the actual array is passed to the formal parameter. 11. Members of a class are usually classified into…arrow_forwardYou need to write a loop that will repeat exactly 125 times. Which is the preferred loop construct to use? A. while B. do while loop C. for looparrow_forwardprogram using a while loop that lets the user enter a series of integers. The user should enter 10 values and the program will display the two largest numbers. You can only use a number once.arrow_forward
- The while loop checks the loop-continuation-condition ______. Select one: a. First b. Last c. Continuously as the loop executes. d. Only when the loop-continuation-condition changes.arrow_forwardIn C, Write a statement that terminates the current loop when the value of the int variables x. and y are equalarrow_forwardYou will write a program that calculates gas milage, also known as fuel economy. The program will use a while loop to repeatedly ask the user for the number of miles driven and gallons of gas used at their last fill up. On each iteration of the loop, your program will calculate the mileage for each fill up. The user will be able to exit the loop by pressing the enter key. After the user exits the loop, the program will print the cumulative gas mileage, by dividing the cumulative number of miles by the cumulative number of gallons. The floating point output should be printed to one decimal place of precision. Here is an example of how the program should work: Your Personal Fuel Economy Number of miles traveled (or enter to exit):380 Number of gallons needed: 12 Mileage this tank: 31.7 Number of miles traveled (or enter to exit): 235 Number of gallons needed:9 Mileage this tank: 26.1 Number of miles traveled (or enter to exit): Average mileage: 29.3arrow_forward
- 2. Task 1: Using do-while loop Write a do-while loop which validate and evaluate the input value for variable grade. NOTE:The program will force the user to enter a valid grade.When the user enter a valid grade, the program will evaluate the grade as passing or failing grade.When the user enter an invalid grade, the program will only allow 3 invalid grade input.Valid grade is from 0 to 100 only.Passing grade is from 70 to 100.Failing grdae is from 0 to 69. NOTE:Your source code must display any of the given sample output below.It means your source code should be flexible enough to meet any of the given sample output.Your source code output must be identical to any of the given sample output.It means you have to strictly follow what are the displayed text, labels, casing of characters in the sample output. OUTPUT 1 Enter Grade: 100 Remark: Passed OUTPUT 2 Enter Grade: 69 Remark: Failed OUTPUT 3 Enter Grade: -1 Remark: Invalid Enter Grade: 101…arrow_forwardTrue or False? In a do…while loop, the condition is checked at the bottom of the loop.arrow_forwardOverview This program will prompt a user for a start and a limit, it will then while-loop through, doubling the iterator each pass, until the limit is reached. Expected Output Example 1 Enter the start of the loop: Enter the limit of the loop: 25 The current value is 3 The current value is 6 The current value is 12 The current value is 24 The last value of current that was less than 25 was 24 Example 2 Enter the start of the loop: 25 Enter the limit of the loop: 102 The current value is 25 The current value is 50 The current value is 100 The last value of current that was less than 102 was 100 Specifications • You should submit a single file called M5A2.py • It should follow the submission standards outlined here: Submission Standards Your program populate an integer named start using input • Your program populate an integer named limit using input Your program must use an iterator named current Your program must move through the values using a while-loop Tips and Tricks That last…arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning