• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

class 3

 
paul wheaton
Trailboss
Pie
Posts: 21596
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At this point you should have read chapters 1, 4, 7 and 5 in that order. There is no reading assignment this time, but there will be three chapters assigned in the next class.

Assignment 4: Write a program that (algorithmically) shows a times table.
In other words, I want to type
<pre>
java Times
</pre>
and see
<pre>
0 1 2 3 4 5 6 7 8 9
0 0 0 0 0 0 0 0 0 0 0
1 0 1 2 3 4 5 6 7 8 9
2 0 2 4 6 8 10 12 14 16 18
3 0 3 6 9 12 15 18 21 24 27
4 0 4 8 12 16 20 24 28 32 36
5 0 5 10 15 20 25 30 35 40 45
6 0 6 12 18 24 30 36 42 48 54
7 0 7 14 21 28 35 42 49 56 73
8 0 8 16 24 32 40 48 56 64 72
9 0 9 18 27 36 45 54 73 72 81
</pre>

Assignment 6: There once was a wise servant who saved the life of a princess. The king agreed to pay whatever the servant could dream up.
Knowing that the king loved chess, the servant told the king he would like to have grains of wheat. One grain on the first square of a chess board. Two grains on the next. Four on the third, and so on.
There are 64 squares on a chessboard.
Write a program that shows how many grains were on each square and the total number of grains.
In other words, I want to type
<pre>
java Grains
</pre>
and see
<pre>
square 1 has 1 grain
square 2 has 2 grains
square 3 has 4 grains
square 4 has 8 grains
</pre>
...

Assignment 7: Write a program that will add the following floating point numbers together:
<pre>
2.222
15.444
27.111
1.001
3.915
7.777
8.888
9.999
12.121
11.522
</pre>
These numbers add up to 100. Print the total, and then print a statement of whether or not the total is equal to 100.000.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic