RU beehive logo ITEC dept promo banner
ITEC 120
2008fall
aaray,
ejderrick,
ibarland,
jmdymacek

homeinfolabshwsexams
textbookjava.lang docsjava.util docsarchive

hw05
arithmetic, constants, static methods

This week's homework is shorter (no project problems), but is due Oct.13 (Mon).
You may turn it in by 17:00 (under the prof's door), if you haven't finished it by the start of class.
  1. R4.7, [casting vs rounding] (2ed: R4.6)
    To illustrate your answer, give (i) a doubles where casting-to-int gives a different answer from Math.round, and (ii) give a double where both approaches give the same answer.
    (You can check your answers easily with BlueJ's Code Pad.)
  2. R4.16 [arithmetic results] (2ed: R4.16)
    Which of the answers seems most non-intuitive to you? You are urged to check your answers with BlueJ's Code Pad.

The remaining problems are from javabat.com, a website where you enter code on a web page, and that site compiles, runs, and tests your program. Its problems do not require classes which contain fields.1 You do not need to create an account on that site, to use it.2

After you get your problem working, copy/paste the code into your printout. If you don't get the code working, clearly state this in your solution.

You can find documentation for class String by following the "java.lang docs" navigation-link at the top of this page.

  1. String1/make�Abba
  2. String1/left2
  3. String1/middleTwo

1 Conceptually, their problems should all be static methods, since the answer depend only on the parameters, not any particular object. However, their site is set up so that you should not actually declare your methods as static.      

2If you do create an account, you can choose to enter your teacher's RU email in the "Teacher Share" field. However, this is not required.      

homeinfolabshwsexams
textbookjava.lang docsjava.util docsarchive


©2008, Ian Barland, Radford University
Last modified 2008.Oct.16 (Thu)
Please mail any suggestions
(incl. typos, broken links)
to iba�rlandrad�ford.edu
Powered by PLT Scheme