Assigned partners for today are...
- Madison and Mustafa
- Noah and Olivia (TeamZoom)
- Jessie and Michaela
- Russ and Blake
- Libby and Nicole
- Haley and Valentino
- Ethan and Mary
- Robert and Nevena
- Izzy, working gloriously alone!
Partner names to the left type first. Your team will work only on this person's account today.
I will tell you when to switch to the second partner typing.
The second partner should not be logged into any machine today.
Machines are ASSIGNED as well. The goal is to work exclusively with your new partner.
If your partner is not here, login into assigned machine and begin working alone.
Once again the first 3 exercises are WARM-UP exercises.
None of them should take your team more than 10min each. They are
all small variations on what we've seen or done before. If your team takes significantly longer on any
of them, take note. You need to try to increase your speed on these types of problems & programs --
on a computer, writing, compiling, & running these and similar programs!
-
Copy, compile, and run program from your textbook Program 1.3.3 Computing powers of 2.
Make sure you understand what it is doing and how it is working.
Now modify the program in the following way:
- System.out.println should be replaced with a properly used SOPf (do not simply replace the ln with an f !!!)
- all coding standards should be adhered to, includes header, renaming, indentation etc...
- print an informative header for two columns, i and 2 to i
- (*) Modify the SOPf line(s) so that all values printed are right-justified within their columns.
-
Write a new program which will print a single row of * characters. The number of stars should be specified by
a command line argument which is strictly positive and less than or equal to 80. If a negative value is entered,
use the absolute value of it. If zero is entered, politely inform user they must enter a non-zero value.
For example, if the user enters
java YourClientName 3
the printed output should be
*** -
Modify the previous program so that every other character is a - instead of a *.
For example, if the user enters
java YourClientName 9
the printed output should be
*-*-*-*-* -
Copy, compile, and run program from your textbook Program 1.3.7 Converting to binary.
Make sure you understand what it is doing and how it is working.
Now modify the program in the following way:
- System.out.print should be replaced with a properly used SOPf It's ok to just add the f thi s time, (-:
- Get 2 user provided integers.
You can get the values from the command line or practice using Scanner if you like. Make sure the first
number is strictly less than the first.
- Next nest the loop from Program 1.3.7 inside another loop. The outter loop should run from
the smaller user value to the larger user value printing one binary number per line for the associated
outter loop variable. Line the decimal numbers up in a right justified field. Don't worry about right justifying
the column of binary numbers.
For example, if the user enters
java BinaryCodeClient 3 12
the printed output should be
3 11
4 100
5 101
6 110
7 111
8 1000
9 1001
10 1010
11 1011
12 1100
-
(Nested Loops.) Modify the previous program to take two command line arguments.
The first will be used as before to print a number of alternating *'s and -'s in a row.
The second will be used to determine the number of rows to print.
For example, if the user enters
java YourClientName 6 3
the printed output should be
*-*-*-
*-*-*-
*-*-*-
-
(Nested Loops.) Write a new program similar to the previous one but this time,
the first command line argument is the number of rows and
the second is the number of characters on each row.
Also this program should make every other row a row start with the opposite character of the one above.
java YourOtherClientName 4 8
the printed output should be
*-*-*-*-
-*-*-*-*
*-*-*-*-
-*-*-*-*