Toggle Code Practice 1b (1.7-1.15)

From CS Awesome 2CC BY-NC-SA 4.0Original page

Java1 class period6 exercises12 graded tests

Files

README.mdDownload

Toggle Code Practice 1b (1.7-1.15)

Each coding exercise has its own folder. Open its .java file and press Run to try it. Run Tests checks every graded exercise in this lesson at once.

For each of the coding problems below, write your own solution.

Exercise 1

Write code that prints a random number from 1 to 50.

Open the 01-u1b-toggle1 folder and edit Test1.java. Press Run to try it; Run Tests checks it (5 tests).

Exercise 2

Write code that prints the first 2 characters of the message followed by the last 2 characters of the message using the appropriate String methods.

Open the 02-u1b-toggle2 folder and edit Test1.java. Press Run to try it; Run Tests checks it (3 tests).

Exercise 3

Write code that prints the first letters in first, middle, and last in lowercase letters using the appropriate String methods.

Open the 03-u1b-toggle3 folder and edit Test1.java. Press Run to try it; Run Tests checks it (1 test).

Exercise 4

Write code that prints the message in all uppercase letters using the appropriate String methods.

Open the 04-u1b-toggle4 folder and edit Test1.java. Press Run to try it; Run Tests checks it (1 test).

Exercise 5

Write code that prints the first 3 letters of the message in uppercase letters using the appropriate String methods.

Open the 05-u1b-toggle5 folder and edit Test1.java. Press Run to try it; Run Tests checks it (1 test).

Exercise 6

Write code that print the part of the message starting with the word “nice” using the appropriate String methods.

Open the 06-u1b-toggle6 folder and edit Test1.java. Press Run to try it; Run Tests checks it (1 test).

For teachers

Toggle Code Practice 1b (1.7-1.15)

Students read CSAwesome2's “Toggle Code Practice 1b (1.7-1.15)” in CS Room and work through its 6 Java coding exercises.

  • Time: 1 class period
  • Tests: 12 in 6 graded exercises, set up for you when you import the lesson

Goals

Before class

In class

  1. Students read README.md.
  2. Students do exercises 01–06, each in its own folder, pressing Run to try their code.
  3. Run Tests checks every graded exercise at once; scores appear in the Gradebook. Grading uses your copy of the tests, so a student who edits theirs does not change the grade.

Exercises

FolderFileGradingTests
01-u1b-toggle1Test1.javaAutograded5
02-u1b-toggle2Test1.javaAutograded3
03-u1b-toggle3Test1.javaAutograded1
04-u1b-toggle4Test1.javaAutograded1
05-u1b-toggle5Test1.javaAutograded1
06-u1b-toggle6Test1.javaAutograded1

Teachers can download a reference solution after signing in.