Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
4th Edition
ISBN: 9780134787961
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 4, Problem 11AW
Write an input validation loop that asks the user to enter a number in the range of 1 through 4,
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
The following for loop should be converted to a while loop:
for a number within the range(25,500,25):
create a printout
2. 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…
.A break statement in the inner loop will terminate both the inner loop and the outer loop. *
(1 Point)
True
False
Chapter 4 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Ch. 4.1 - What will the following program segments display?...Ch. 4.2 - How many times will Hello World be printed in the...Ch. 4.2 - How many times will I love Java programming! be...Ch. 4.3 - Write an input validation loop that asks the user...Ch. 4.3 - Write an input validation loop that asks the user...Ch. 4.3 - Write an input validation loop that asks the user...Ch. 4.5 - Name the three expressions that appear inside the...Ch. 4.5 - You want to write a for loop that displays I love...Ch. 4.5 - What will the following program segments display?...Ch. 4.5 - Write a for loop that displays your name 10 times.
Ch. 4.5 - Write a for loop that displays all of the odd...Ch. 4.5 - Write a for loop that displays every fifth number,...Ch. 4.6 - Write a for loop that repeats seven times, asking...Ch. 4.6 - In the following program segment, which variable...Ch. 4.6 - Prob. 4.15CPCh. 4.10 - What is the difference between an input file and...Ch. 4.10 - What import statement will you need in a program...Ch. 4.10 - What class do you use to write data to a file?Ch. 4.10 - Write code that does the following: opens a file...Ch. 4.10 - What classes do you use to read data from a file?Ch. 4.10 - Write code that does the following: opens a file...Ch. 4.10 - You are opening an existing file for output. How...Ch. 4.10 - What clause must you write in the header of a...Ch. 4.11 - Assume x is an int variable, and rand references a...Ch. 4.11 - Assume x is an int variable, and rand references a...Ch. 4.11 - Assume x is an int variable, and rand references a...Ch. 4.11 - Assume x is a double variable, and rand references...Ch. 4 - Prob. 1MCCh. 4 - Prob. 2MCCh. 4 - Prob. 3MCCh. 4 - What is each repetition of a loop known as? a....Ch. 4 - This is a variable that controls the number of...Ch. 4 - The while loop is this type of loop. a. pretest b....Ch. 4 - The do-while loop is this type of loop. a. pretest...Ch. 4 - The for loop is this type of loop. a. pretest b....Ch. 4 - This type of loop has no way of ending and repeats...Ch. 4 - This type of loop always executes at least once....Ch. 4 - This expression is executed by the for loop only...Ch. 4 - Prob. 12MCCh. 4 - This is a special value that signals when there...Ch. 4 - To open a file for writing, you use the following...Ch. 4 - To open a file for reading, you use the following...Ch. 4 - Prob. 16MCCh. 4 - This class allows you to use the print and println...Ch. 4 - This class allows you to read a line from a file....Ch. 4 - True or False: The while loop is a pretest loop.Ch. 4 - True or False: The do-while loop is a pretest...Ch. 4 - True or False: The for loop is a posttest loop.Ch. 4 - True or False: It is not necessary to initialize...Ch. 4 - True or False: One limitation of the for loop is...Ch. 4 - True or False: A variable may be defined in the...Ch. 4 - True or False: In a nested loop, the inner loop...Ch. 4 - True or False: To calculate the total number of...Ch. 4 - // This code contains ERRORS! // It adds two...Ch. 4 - Prob. 2FTECh. 4 - // This code contains ERRORS! int choice, num1,...Ch. 4 - Prob. 4FTECh. 4 - Write a while loop that lets the user enter a...Ch. 4 - Write a do-whi1e loop that asks the user to enter...Ch. 4 - Write a for loop that displays the following set...Ch. 4 - Write a loop that asks the user to enter a number....Ch. 4 - Write a for loop that calculates the total of the...Ch. 4 - Write a nested loop that displays 10 rows of #...Ch. 4 - Convert the while loop in the following code to a...Ch. 4 - Convert the do-while loop in the following code to...Ch. 4 - Convert the following while loop to a for loop:...Ch. 4 - Convert the following for loop to a while loop:...Ch. 4 - Write an input validation loop that asks the user...Ch. 4 - Write an input validation loop that asks the user...Ch. 4 - Write nested loops to draw this pattern:Ch. 4 - Write nested loops to draw this pattern: ## # # #...Ch. 4 - Complete the following program so it displays a...Ch. 4 - Complete the following program so it performs the...Ch. 4 - Prob. 17AWCh. 4 - Prob. 18AWCh. 4 - Modify the code you wrote in Question 18 so it...Ch. 4 - Write code that opens a file named NumberList.txt...Ch. 4 - Prob. 1SACh. 4 - Why should you indent the statements in the body...Ch. 4 - Describe the difference between pretest loops and...Ch. 4 - Why are the statements in the body of a loop...Ch. 4 - Describe the difference between the while loop and...Ch. 4 - Which loop should you use in situations where you...Ch. 4 - Which loop should you use in situations where you...Ch. 4 - Which loop should you use when you know the number...Ch. 4 - Why is it critical that accumulator variables are...Ch. 4 - What is an infinite loop? Write the code for an...Ch. 4 - Prob. 11SACh. 4 - What does it mean to let the user control a loop?Ch. 4 - What is the advantage of using a sentinel?Ch. 4 - Prob. 14SACh. 4 - Describe a programming problem requiring the use...Ch. 4 - How does a file buffer increase a programs...Ch. 4 - Why should a program close a file when its...Ch. 4 - What is a files read position? Where is the read...Ch. 4 - When writing data to a file, what is the...Ch. 4 - What does the Scanner classs hasNext method return...Ch. 4 - What is a potential error that can occur when a...Ch. 4 - Prob. 22SACh. 4 - How do you open a file so that new data will be...Ch. 4 - Sum of Numbers Write a program that asks the user...Ch. 4 - Distance Traveled The distance a vehicle travels...Ch. 4 - Distance File Modify the program you wrote for...Ch. 4 - Pennies for Pay Write a program that calculates...Ch. 4 - Prob. 5PCCh. 4 - File Letter Counter Write a program that asks the...Ch. 4 - Hotel Occupancy A hotels occupancy rate is...Ch. 4 - Average Rainfall Write a program that uses nested...Ch. 4 - Population Write a program that will predict the...Ch. 4 - Largest and Smallest Write a program with a loop...Ch. 4 - Celsius to Fahrenheit Table Write a program that...Ch. 4 - Bar Chart Write a program that asks the user to...Ch. 4 - File Head Display Write a program that asks the...Ch. 4 - Line Numbers Write a program that asks the user...Ch. 4 - Uppercase File Converter Write a program that asks...Ch. 4 - Budget Analysis Write a program that asks the user...Ch. 4 - Random Number Guessing Game Write a program that...Ch. 4 - Random Number Guessing Game Enhancement Enhance...Ch. 4 - ESP Game Write a program that tests your ESP...Ch. 4 - Square Display Write a program that asks the user...Ch. 4 - Dice Game Write a program that plays a simple dice...Ch. 4 - Prob. 22PCCh. 4 - Personal Web Page Generator Write a program that...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What is denormalization?
Database Concepts (8th Edition)
For each of the following activities, give a PEAS description of the task environment and characterize it in te...
Artificial Intelligence: A Modern Approach
Convert the following for loop to a while loop: for (int x = 50; x 0; x--) { System.out.println(x + seconds t...
Starting Out with Java: From Control Structures through Objects (6th Edition)
Write a loop equivalent to the for loop above without using .
C Programming Language
This operator performs division, but instead of returning the quotient it returns the remainder. a. % b. c. d...
Starting Out with Python (3rd Edition)
Are the Book objects you have implemented immutable? Justify your answer.
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- (Misc. application) a. Write a program that continuously requests a grade to be entered. If the grade is less than 0 or greater than 100, your program should print an appropriate message informing the user that an invalid grade has been entered; else, the grade should be added to a total. When a grade of 999 is entered, the program should exit the repetition loop and compute and display the average of the valid grades entered. b. Run the program written in Exercise 2a and verify the program by using appropriate test data.arrow_forwardQI: - Design a form and write a code to find the average value of N degrees using For Next Loop. Use InputBox function to read degrees. Q2: - Design a form and write a code to find the largest value of N numbers using Do While Loop. Use InputBox function to read numbers. Q3: - Write VB program using Do Loop While to read 7 marks, if pass in all marks (>=50) print "pass" otherwise print "fail". Use input box to read marks. Q4: - Write VB program using Do Until Loop to find the summation of student's marks, and it's average, assume the student have 8 marks. Use InputBox function to read marks.arrow_forwardIn while loop, the loop continues if test expression(condition between small brackets) is a. true b.false c. neither a nor barrow_forward
- Pls do flowchart for this // This pseudocode is intended to determine whether students have // passed or failed a course; student needs to average 60 or // more on two tests. start Declarations num firstTest num secondTest num average num PASSING = 60 // input of first test score output "Enter first score or 0 to quit " input firstTest // loop that continues until the user enters 0 as first test score while firstTest not equal to 0 // input of second test score output "Enter second score or 0 to quit" input secondTest // if second test score is not 0 then calculate and display average and display if the student passed or failed if secondTest is not equal to 0 // calculate and display average average = (firstTest + secondTest) / 2 output "Average is ", average misspelled "t" for the word output // determine if the student passed or failed…arrow_forwardIn C#arrow_forwardPart A: While Loop ProgramWrite a program that detects Fibonacci numbers. Prompt the user to input a positive integer. Upon input, the program will determine if the number is either a Fibonacci number or not. If a Fibonacci number, then the order of the number in the sequence must be output. If not a Fibonacci number, then the Fibonacci numbers above and below it (including their order in the sequence) must be output. Once it finishes, the program will prompt the user for a new number. The program will exit if the user enters a non-integer number or string (such as “quit”) instead of an integer. Use the sample output file, fib-seq-det.txt, to view a sample session For both the above problems, the first four numbers of the Fibonacci sequence are 0, 1, 1, and 2. Part A must use While loops only. Invalid (negative) numbers should be flagged and handled. Output should be like: Welcome to the Fibonacci Sequence Detector Please input a number for analysis >> 00 is a…arrow_forward
- The following for loop should be converted to a while loop: for a number in the range(90,9,-9): create a printoutarrow_forwardWrite a nested loop that displays 10 rows of '#' characters. There should be 15 '#' characters in each row.arrow_forward(Mathematical functions) Write a program that calculates and displays values for y when y=xz/(xz) Your program should calculate y for values of x ranging between 1 and 5 and values of z ranging between 2 and 6. The x variable should control the outer loop and be incremented in steps of 1, and z should be incremented in steps of 1. Your program should also display the message Function Undefined when the x and z values are equal.arrow_forward
- All of the following are looping control structures except Select one: while loop do-while loop for loop do loop none; all of these are looping control structuresarrow_forwarduse kotlin code pleasearrow_forwardA for loop is a ______ loop. Select one: a. Limit-controlled b. Function-controlled c. Range-controlled d. Count-controlledarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming Tutorial 36 - Intro to Loops; Author: Caleb Curry;https://www.youtube.com/watch?v=M3o7Y0juEP0;License: Standard YouTube License, CC-BY