Homework #1 – Java 211, Mendelsohn

 

TIP:  Always begin SMALL and SIMPLE.  Begin with an extremely simple program.  Compile and run it.  If it works begin adding extra functionality.

 

This assignment will be due on Tuesday at 10 am. Remember that COL will not accept assignments beyond that time, so don’t wait until the last minute to turn it in!

 

For all of these problems, you can “hard code” a value when testing your program.  For example, in the first problem, you can choose a value for miles (e.g.  double miles = 44.2;  ). You can then proceed with the conversion. Next week we will talk about how to have our programs read in a value from the user instead of having to hard-code those values ourselves. 

 

Remember:

-          Follow proper naming conventions for classes, variables, constants, etc

-          Use enough whitespace to make sure your code is easy to read.

-          Use proper indenting

 

  1. Say you are about to take a road trip through the Canadian wilderness.  Create a class called ‘DistanceConvert’ that will convert miles to kilometers.  The formula is kilometers = miles * 1.6.
  2. The area of a circle is calculated by the formula: area = pi * radius * radius.  The formula for circumference is 2 * pi * radius.  As mentioned earlier, you may hard-code the value for the radius (e.g. double radius = 3.4; ).  Calculate both the area and circumference and output those values to the console window.
  3. Create a class in which you have two variables of type ‘double’.  Have a third variable called ‘dividend’.  Inside this third variable store the result of the first variable divided by the second variable. Output the result to the console window.

 

Notes:

-          Submit only your source code files for the three classes. 

-          Submit them as a ZIP file . If you do not know how to Zip files, you can view a rather detailed tutorial here.

-          Remember that assignments are submitted on COL.