
Java: An Introduction to Problem Solving and Programming (7th Edition)
7th Edition
ISBN: 9780133766264
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 4.1, Problem 4STQ
Revise the following code so that it uses a while loop instead of a do-while loop:
Scanner keyboard = new Scanner(System.in);
int number;
do
{
System.out.println("Enter a whole number:");
number – keyboard.nextInt();
System.out.println("You entered" + number);
} while (number > 0);
System.out.println("number after loop = '' + number);
Expert Solution & Answer

Want to see the full answer?
Check out a sample textbook solution
Students have asked these similar questions
Please write on C++ programming
LAB
ACTIVITY
21.16.1: LAB*: Program: Rock paper scissors
Exit Full screen
0/10
Program Specifications Write a program to play an automated game of Rock, Paper, Scissors. Two players make one of
three hand signals at the same time. Hand signals represent a rock, a piece of paper, or a pair of scissors. Each combination
results in a win for one of the players. Rock crushes scissors, paper covers rock, and scissors cut paper. A tie occurs if both
players make the same signal. Use a random number generator of 0, 1, or 2 to represent the three signals.
Note: this program is designed for incremental development. Complete each step and submit for grading before starting the
next step. Only a portion of tests pass after each step but confirm progress.
Step 0. Read starter template and do not change the provided code. Integer constants are defined for ROCK, PAPER, and
SCISSORS. A Random object is created and a seed is read from input and passed to the Random object. This supports
automated…
20.22: LAB*: Program: Text message decoder
20.22 LAB*: Program: Text message decoder
LAB
ACTIVITY
20.22.1: LAB*: Program: Text message decoder
Full screen
0/6
☐
Program Specifications Write a program that reads a line of text message and identifies any supported
abbreviations in the text.
Note: This program is designed for incremental development. Complete each step and submit for grading before
starting the next step. Only a portion of tests pass after each step but confirm progress.
Step 1 (3 pts): Read and verify user input.
Use getline() to read a line of user input into a string. Output the string. Submit for grading to confirm 2 tests
pass.
Ex: If the input is:
Enter text:
IDK if I'll go. It's my BFF's birthday.
the output is:
You entered: IDK if I'll go. It's my BFF's birthday.
Step 2 (3 pts): Identify abbreviations.
Search the string (by using find()) for any supported abbreviations and print a list of found abbreviations along
with the decoded meaning. Assume each unique…
Chapter 4 Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Ch. 4.1 - What output is produced by the following code? int...Ch. 4.1 - Can the body of a while loop execute zero times?...Ch. 4.1 - What output is produced by the following code? int...Ch. 4.1 - Revise the following code so that it uses a while...Ch. 4.1 - What output is produced by the following code? int...Ch. 4.1 - Imagine a program that reads the population of a...Ch. 4.1 - Prob. 7STQCh. 4.1 - What output is produced by the following code? int...Ch. 4.1 - What output is produced by the following code? for...Ch. 4.1 - What output is produced by the following code? for...
Ch. 4.1 - Prob. 11STQCh. 4.1 - Write a for statement that displays the even...Ch. 4.1 - Prob. 13STQCh. 4.2 - Write a Java loop that will display the phrase One...Ch. 4.2 - Write a Java loop that will set the variable...Ch. 4.2 - Write a Java loop that will read a list of numbers...Ch. 4.2 - What output is produced by the following code? for...Ch. 4.2 - What output is produced by the following code? for...Ch. 4.2 - What output is produced by the following code? for...Ch. 4.2 - Revise the loop shown in Listing 4.6 to use a...Ch. 4.2 - What is the bug in the code in the section Tracing...Ch. 4.2 - Add some suitable output statements to the...Ch. 4.2 - What is the bug in the code in the previous...Ch. 4.2 - Prob. 24STQCh. 4.2 - Suppose that you did not have assertion checking...Ch. 4.3 - Prob. 26STQCh. 4 - Write a fragment of code that will read words from...Ch. 4 - Develop an algorithm for computing the...Ch. 4 - Develop an algorithm for a simple game of guessing...Ch. 4 - Write a fragment of code that will compute the sum...Ch. 4 - Convert the following code so that it uses nested...Ch. 4 - Write a for statement to compute the sum 1 + 22 +...Ch. 4 - (Optional) Repeat the previous question, but use...Ch. 4 - Write a loop that will count the number of blank...Ch. 4 - Write a loop that will create a new string that is...Ch. 4 - Write a program that will compute statistics for...Ch. 4 - Suppose we attend a party. To be sociable, we will...Ch. 4 - Define an enumeration for each of the months in...Ch. 4 - Write a fragment of code that computes the final...Ch. 4 - Suppose that you work for a beverage company. The...Ch. 4 - Suppose that we want to compute the geometric mean...Ch. 4 - Prob. 16ECh. 4 - Create an applet that draws a pattern of circles...Ch. 4 - Prob. 18ECh. 4 - What does the following fragment of code display?...Ch. 4 - Repeat Practice Program 4 of Chapter 3, but use a...Ch. 4 - Write a program that implements your algorithm...Ch. 4 - Repeat Practice Program 5 of Chapter 3, but use a...Ch. 4 - Write a program to read a list of nonnegative...Ch. 4 - Write a program to read a list of exam scores...Ch. 4 - Combine the programs from Programming Projects 5...Ch. 4 - Write a program that simulates the Magic 8 Ball...Ch. 4 - Whats for dinner? Let the computer decide. Write a...Ch. 4 - Write a program that implements your algorithm...Ch. 4 - Prob. 2PPCh. 4 - Write a program that reads a bank account balance...Ch. 4 - Modify Programming Project 5 from Chapter 2 to...Ch. 4 - Write a program that asks the user to enter the...Ch. 4 - Write a program that simulates a bouncing ball by...Ch. 4 - You have three identical prizes to give away and a...Ch. 4 - Prob. 9PPCh. 4 - Holy digits Batman! The Riddler is planning his...Ch. 4 - Your country is at war and your enemies are using...Ch. 4 - Prob. 12PPCh. 4 - Prob. 13PPCh. 4 - Prob. 14PPCh. 4 - Prob. 15PPCh. 4 - Prob. 16PP
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
True or False: A subclass reference variable can reference an object of the superclass.
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Distinguish among data definition commands, data manipulation commands, and data control commands.
Modern Database Management
Indicate whether each of the following relational expressions is true or false. Refer to the ASCII table in App...
Starting Out with C++: Early Objects (9th Edition)
What is an object?
Starting Out With Visual Basic (8th Edition)
This optional Google account security feature sends you a message with a code that you must enter, in addition ...
SURVEY OF OPERATING SYSTEMS
Consider the following C program void fun (void) { int a, b, c; / defiinition.1 / . . . while (. . .) int b, c,...
Concepts Of Programming Languages
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
- The Greatest and Least of These Write a program with a loop that lets the user enter a series of integers. The user should enter -99 to signal the end of the series. After all the numbers have been entered, the program should display the largest and smallest numbers entered. Input your program in the blank textbox, run it against the web based C++ tool to ensure it compiles Please make sure to comment your code, this is worth 3 points for this question. 114 Edit View Insert Format Tools Table 1201 Search F3 F4 F5 A PrtScn Hom F6 F7 F8arrow_forwardKS My library> CS 20.4 LAB: Max of 3 LAB ACTIVITY 20.4.1: LAB: Max of 3 Full screen 0/10 Write a program that takes in three integers as inputs and outputs the largest value. If the input integers are the same, output the integers' value. Ex: If the input is: 1 2 3 the output is: Max of [1, 2, 3] is 3 Run main.cpp #include 1 2 using namespace std; 3 4 int main() { 5 int vall; Q Search Open new tab El Do History Tuarrow_forward21.5: LAB: Countdown until matching digits 21.5 LAB: Countdown until matching digits LAB ACTIVITY 21.5.1: LAB: Countdown until matching digits Full screen 0/10 Write a program that takes in an integer in the range 11-99 (inclusive) as input. The output of the program is a countdown starting from the input integer until an integer where both digits are identical. End with a newline. Ex: If the input is: 93 the output is: 93 92 91 90 89 88 Ex: If the input is: 11 the output is: 11 Ex: If the input is: or any value not between 11 and 99 (inclusive), the output is: Input must be 11-99 For coding simplicity, follow each output number by a space, even the last one. Use a while loop. Compare the digits; do not write a large if-else for all possible same-digit numbers (11, 22, 33,.... 99), as that approach would be cumbersome for larger ranges. Run main.cpp 1 #include 2 using namespace std; 3 4 int main() { 5 6 7 8 / Type your code here. */ return 0; 9 } 10 Open new tab Dock History Tutorial…arrow_forward
- 23.2 LAB: Step counter LAB ACTIVITY 23.2.1: LAB: Step counter Full screen 0/10 A pedometer treats walking 1 step as walking 2.5 feet. Define a function named FeetToSteps that takes a double as a parameter, representing the number of feet walked, and returns the number of steps walked as an integer by type casting. Then, write a main program that reads the number of feet walked as an input, calls function FeetToSteps() with the input as an argument, and outputs the number of steps returned from FeetToSteps(). Use floating-point arithmetic to perform the conversion. Note: Type casting a double to an integer may affect the result's accuracy. Ex: If the input is: 150.5 the output is: 60 The program must define and call a function: int FeetToSteps (double userFeet) Run main.cpp 1 #include 2 #include 3 using namespace std; 4 5 /* Define your function here */ 6 7 int main() { 8 / Type your code here */ 9 10 return 0; 11 12 Open new tab Dock History Tutorial ENG 3:05 PMarrow_forward19.11 LAB: Convert to seconds LAB ACTIVITY 19.11.1: LAB: Convert to seconds LJ Full screen Write a program that reads in seconds, minutes, and hours as input, and outputs the time in seconds only. Ex: If the input is: 40 6 1 where 40 is the number of seconds, 6 is the number of minutes, and 1 is the number of hours, the output is: 4000 seconds ▷ Run main.cpp #include 1 2 using namespace std; 3 4 int main() { 5 int seconds; int minutes Q Search Open new tab History H Warrow_forwardThe Greatest and Least of These Write a program with a loop that lets the user enter a series of integers. The user should enter-99 to signal the end of the series. After all the numbers have been entered, the program should display the largest and smallest numbers entered. Input your program in the blank textbox, run it against the web based C++ tool to ensure it compiles Please make sure to comment your code, this is worth 3 points for this question. Edit View Insert Format Tools Table 12pt v Paragraph BIUA T² v هم ...arrow_forward
- Areas of Rectangles The area of a rectangle is the rectangle's length times its width. Write a program that asks for the length and width of two rectangles. The program should tell the user which rectangle has the greater area, or if the areas are the same. Input your program in the blank textbox, run it against the web based C++ tool to ensure it compiles Please make sure to comment your code, this is worth 3 points for this question. Edit View Insert Format Tools Table 12pt v Paragraph BIUA T² Varrow_forwardMiles per Gallon Write a program that calculates a car's gas mileage. The program should ask the user to enter the number of gallons of gas the car can hold and the number of miles it can be driven on a full tank. It should then display the number of miles that may be driven per gallon of gas. Input your program in the blank textbox, run it against the web based C++ tool to ensure it compiles Please make sure to comment your code, this is worth 3 points for this question. Edit View Insert Format Tools Table 12pt v Paragraph BIUAarrow_forwardRead Chapter 1 of Ralph Stair's textbook, "Fundamentals of Information Systems," 9th Edition, and then write a response to the two discussion questions. Your response should be between half and a page long. Describe how you might use information systems in a career area of interest to you. What things might managers in an organization do that could unintentionally discourage innovation by their employees? How can innovation be encouraged?arrow_forward
- Python question:arrow_forwardPayroll Flowchart Analysis Discuss the risks depicted by the following payroll system flowchart. Describe the internal control improvements to the system that are needed to reduce these risks with specific explanations. An illustration of the above flowchart: It is represented in six columns and the column header reads: supervisor; payroll; data processing; accounts payable; cash disbursement; general ledger. In supervisor column, timekeeper enters into time cards and that leads to “Review Time cards and prepares Personnel Action Form” that further leads to two source documents “time cards, per action form.” Per action, form enters into prepare payroll in payroll column. Prepare payroll enters into paychecks and two source documents “payroll register, payroll register.” Payroll register leads to inverted triangle and payroll leads to A. Paycheck enters into review and distribute in supervisor column leads to paycheck and that further leads to employees. In data processing column,…arrow_forwardUsing the following execution shown below, explain what is done in each of the ARIES recovery algorithm phases: LSN LOG 00 begin_checkpoint 10 end_checkpoint 20 update: T1 writes P1 30 update: T2 writes P2 40 update: T3 writes P3 50 T2 commit 60 update: T3 writes P2 70 T2 end 80 update: T1 writes P5 90 T3 abort CRASH, RESTART In addition to the execution shown here, the system crashes during recovery after writing two log records to stable storage and again after writing another two log recordsarrow_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,
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ 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,

Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning

EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT

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