
CSE 283 Introduction to Object Oriented DesignBarbara Nostrand, Ph.D. 
CSE 283 Labs 

Lab 3: Projects
Objectives1. Gain further experience constructing expressions.
IntroductionEach of the following projects involves the construction of expressions of various types, and so will provide practice in building expressions. Your instructor will tell you which one to do. Projects3.1. Finish the lab exercise by completing the remaining experiments. 3.2. Write a program that finds the resistance of an electronic circuit with three parallel resistors resistor1, resistor2, and resistor3. The resistance can be computed using the following formula: 1 resistance =  1 1 1  +  +  resistor1 resistor2 resistor3 3.3. The two solutions of a quadratic equation y = ax^{2} + bx + c can be found using the quadratic formula: solution1 = b + the square root of (b^{2}  4ac)  2a and solution2 = b  the square root of (b^{2}  4ac)  2a Write a program that inputs values for a, b and c, and outputs the values of solution1 and solution2. Use boolean expressions to print out true/false depending on if
3.4. Write a GUIbased program called Remember that floating point numbers may be approximations to the number intended and not exact values. This can cause small errors in the lowest order digit. For example, 0.03 can not be exactly represented in binary. Rather, the binary expansion of 0.03 is of infinite length much as 1/3 is approximated by 0.333333... in decimal notation. Floating point representations of positive numbers will generally be less than or equal to their true value. You can correct this problem by adding a small value which will force the binary representation to be slightly larger than the true value. Another problem is caused by entering values with too many digits after the decimal point. We could simply ignore these small errors, but we should check user input for correct format before using the input. Here is a simple program fragment which should give you an idea for how to check a double called value for acceptable U.S. currency values: double value = Double.parseDouble(keyboard.readLine()); int pennies = (int)(100*value); double test = Double.parseDouble(Double.toString(((double)pennies)/100)); screen.println(value); screen.println(test);After completing a transaction, Change prompts the user for another transaction. Do not use any conditional staments such as if to compute the change for a transaction.

Home


Last modified: 2007 OCT 28 bnostran@syr.edu 