Computer Science 202
Introduction to Programming
Fall 2012, The College of Saint Rose
Agenda
We will work together to develop a Java program that will include a class to represent a circle and another class that will create and work with some circles. You may work alone or with a partner on this exercise in class.
Our circles will not actually be drawn on the screen, but we will store information that could be used to do so. We will maintain 3 pieces of information about the circles:
We will develop a class called Circle which stores the above data, and includes methods to create a circle, query its center, query its radius, query its color, query its top, bottom, left end right edges, query its diameter, and obtain a String description of the circle. Additional methods will allow the center, radius, diameter, and color to be modified.
We will also develop a class called CircleMaker that we will use to test the constructors and other methods of the Circle class.
Submit your Java files Circle.java and CircleMaker.java in Blackboard under the "Lecture Assignment Submissions" category to the "Lecture 25 In-Class Exercise" item. This will earn you 10 lecture assignment points. Make sure your name(s) is/are in each of the files you submit.
No New Lecture Assignment
Obviously.
But here are some exam practice questions you might want to look at:
So for an item that costs $12.99 and weighs 6 ounces, the shipping cost is computed as $0.75 + 6 * $0.25 = $2.25. For an item that costs $150.00, shipping costs $0.00.
Also write calls to the method that compute the shipping costs for the 2 above examples, placing the results in variables named cheapItem and expensiveItem.
public class NeedsMethod { public static void main(String[] args) { int fact = 1; for (int number = 5; number >= 1; number--) { fact *= number; } System.out.println("5! = " + fact); fact = 1; for (int num = 9; num >= 1; num--) { fact *= num; } System.out.println("9! = " + fact); int f = 1; for (int number = 12; number >= 1; number--) { f *= number; } System.out.println("12! = " + f); } }
Examples