Coding Practice

The E01PrintEven program should generate a random number and print if it is evenly divisible by 2. However, the code has an error and always prints “Your number is even”, even if the random number is odd. Fix the code so that it only prints the message when the number is even.

The E02CheckGuess program should check your guess against the answer and print that it is too low, correct, or too high. However, the code has errors. Fix the code so that it compiles and runs correctly.

The E03Chores program should print “You can go out” if you have done your homework and cleaned your room. However, the code has errors. Fix the code so that it compiles and runs correctly.

The E04TestRange program should print if x is in the range of 0 to 10 (including 0 and 10). However, the code has errors. Fix the errors so that the code runs as intended.

The E05PositiveNegativeZero program should print if x is less than 0, equal to 0, or greater than 0. Finish it to work correctly.

Finish the E06Fever program so that it prints You have a fever if your temperature is above 100 and otherwise prints You don't have a fever.

Finish the E07Temperature program to print It is freezing if the temperature is below 30, It is cold if it is below 50, It is nice out if it is below 90, or It is hot using nested if else statements.

Rewrite the E08LoopRewrite1 program to use a while loop instead of a for loop to print out the numbers from 1 to 10 (inclusive).

Rewrite the E09LoopRewrite2 program so that it uses a for loop instead of a while loop to print out all the integers from 5 to 15 (inclusive).

Rewrite the E10LoopRewrite3 program to use a while loop instead of a for loop to print out the numbers from 10 to 100 by 10’s (inclusive).

The E11Errors1 program should print the values from 1 to 10 (inclusive) but has errors. Fix the errors so that the code works as intended. If the code is in an infinite loop you can refresh the page in the browser to stop the loop and then click on Load History and move the bar above it to see your last changes.

The E12Errors2 program should print the values from 10 to 5, but it has errors. Fix the errors so that the code works as intended.

The E13Errors3 program should print the values from 10 to 1, but it has errors. Fix the errors so that the code works as intended.

Finish E14Countdown program to print a countdown from 100 to 0 by 10’s using a for or while loop.

Finish the E15EvenOdd program to print the value of x and " is even" if x is even and " is odd" if it is odd for all values from 10 to 1.

Finish the E16Multiply program to print the values for 10 * x where x changes from 0 to 10 using a loop.

Finish the E17 program so that it prints a string message minus the last character each time through the loop until there are no more characters in message. The loop condition should test the length of the message. The loop body should print the message and then use substring to create a new message without the last character.

Finish E18MessageX program to loop printing the message each time through the loop and remove an x from the message until all the x’s are gone.

Write a loop in the E19CountX program to print the number of x’s in the string message. Use the indexOf and substring methods.

Write the E20Rectangle5x3 program to print a rectangle of stars (*) with 5 rows of stars and 3 stars per row. Hint: use nested for loops.

Write the E21Rectangle3x5 program to print a rectangle of stars (*) with 3 rows of stars and 5 stars per row.

Write the E22NumberTriangle program to print 55555, 4444, 333, 22, 1 with each on a different line.

You have attempted of activities on this page