some simpler exercises for IFs and loops.
Ryan Small d2fc8d8853 i hope this is right 6 år sedan
.idea i hope this is right 6 år sedan
src i hope this is right 6 år sedan
untitled i hope this is right 6 år sedan
.DS_Store i hope this is right 6 år sedan
README.md Update 'README.md' 6 år sedan
Saturday-Exercises.iml i hope this is right 6 år sedan
SaturdayPractice i hope this is right 6 år sedan

README.md

Saturday-Exercises

some simpler exercises for IFs and loops.

Happy 1st Saturday, Newbies!

Yes, I am writing these on my phone, from I-70west in Ohio. No, I am not currently driving.

Some extra (easier) exercises.

Use them to practice writing both pseudo code and Java. Write each one in both.

Strive to feel good about the practice as you complete each one.

I suggest you write them into a notebook or onto paper. Once, you written them all, go thru them and type them into this file. You can use “atom” for that.

Then, if you’d like comments on your work, do a Pull Request and make the title of the PR “comments please”.

IFs

Write an IF statement that checks “player1.isAlive()” and if that’s false, calls “displayGameOver(player1)”

Write an IF statement that checks the “temperature(room)” and if that check is less than 70, calls “heatOn()” else calls “coolOn()”

Write an IF statement that checks “outsideTemp()” is less than 50 AND “insideTemp()” is less than 62, calls “startAFire(fireplace1)”

Write an IF statement that checks “fuelLevel” and if that check is less than 0.08, calls “refuel()”

Loops

For each loop you write, print “Hello” on each loop iteration.

Write a FOR loop that counts from 1 to 10.

Write a FOR loop that makes 10 iterations, start at 21

Write a FOR loop that counts down from 100 to 0

Write a FOR loop from 0 to 32 by 2s

Write a FOR loop from 1 to less than 5001 by 11s.

Write a nested FOR loop(s), where one counts from 0 to less than 20 and the inner one counts from 0 to 4.

Write a FOR loop that counts from 5 to 105. Put an IF statement inside the loop that checks the loop index counter and if it’s greater than 51, prints “Hello Zipcode” instead on “hello”

Write a WHILE loop that checks “gps.currentLocation()” and if that is not equal to “Home” then and it calls “driveSomeMore()”. After the loop is done, print “Honey, I’m Home!”

First set “highestScore” to 0. Then set “currentScore” to “game.nextScore()”. Then write a WHILE loop that checks “currentScore” is greater than “highestScore” and if it is, sets “highestScore” to “currentScore” and then sets “currentScore” to “game.nextScore()”.

Rewrite the previous WHILE loop as a REPEAT..UNTIL loop. Notice how the “currentScore” variable usage is different.

Write a WHILE loop that checks “server.isRunning()” and if true calls “waitFor(5)” After the loop, write an IF and check “server.isRunning()” is false, and if so, call “sendEmergencyText(“Help!”, admin.iPhoneNumber)” and also calls “tryServerRestart()”

Declare an “int” i. Set i to 7. Write a WHILE loop that checks “i” is less than 50, and if it is, add 7 to “i”

Given an array voteTallies[], write a FOR loop that prints out each value in the array.

Given an array voteTallies[], write a WHILE loop that prints out each value in the array. You should declare and use an index “idx” to keep track of where you are.

Ponder this: can all FOR loops be rewritten as WHILE loops?

Ponder this: can all WHILE loops be rewritten as FOR loops?

Set “yardNeedsMowed” to true. Write WHILE loop that checks for “isSummer()”. inside the loop, write an IF that checks “yardNeedsMowed” and if true calls “yellAtJunior(chores.mowLawn())” After loop, call “sendJuniorToSchool(onTime)”