Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a while loop Let's get you started with building a while loop from the ground up . Have another look at its recipe: while

Write a while loop
Let's get you started with building a while loop from the ground up. Have another look at its recipe:
while (condition){
expr
}
Remember that the condition part of this recipe should become FALSE at some point during the execution. Otherwise, the while loop will go on indefinitely.
If your session expires when you run your code, check the body of your while loop carefully.
Have a look at the sample code provided; it initializes the speed variables and already provides a while loop template to get you started.
Instructions
100 XP
Code a while loop with the following characteristics:
The condition of the while loop should check if speed is higher than 30.
Inside the body of the while loop, print out "Slow down!".
Inside the body of the while loop, decrease the speed by 7 units and assign this new value to speed again. This step is crucial; otherwise your while loop will never stop and your session will expire.
If your session expires when you run your code, check the body of your while loop carefully: it's likely that you made a mistake.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design

Authors: Marion Donnie Dutton Don F. Seaman

14th Edition Globel Edition

1292107634, 978-1292107639

More Books

Students also viewed these Databases questions

Question

c. What were the reasons for their move? Did they come voluntarily?

Answered: 1 week ago

Question

5. How do economic situations affect intergroup relations?

Answered: 1 week ago