/** * CS1322: Programming Assignment #0 - Fall 2002 * *
 *  P0Phase3.java
 *  Class P0Phase3 - A class designed to learn methods and
 *    casting, as well as working with expressions.
 *
 *  Revisions: 1.0 Aug. 26, 2002
 *               Created the P0Phase3 class
 *
 *             1.1 Aug. 26, 2002
 *               Finished, Compiled, Tested
 *
 *  
* * Collaboration Statement: * I worked on the homework assignment alone, using only * course materials. * * @author Jose Manuel Caban * @version Version 1.1, Aug. 26, 2002 */ public class P0Phase3 { /////////// //Methods// /////////// /** * Truncate double value into an int * *

* @param d, value to be truncated * @return truncated value d */ public int roundOff(double d){ return ((int) d); } /** * Divide dividend by divisor * *

* @param dividend, value to be divided * @param divisor, parts that the divisor will be split into * @return quotient of dividend and divisor */ public double divide(int dividend, int divisor){ return (((double)dividend / divisor)); } /** * Mulitply x by 2.5 * *

* @param x value to be multiplied by 2.5 * @return value of x*2.5 */ public double twoANDAHalfTimes(int x){ return ((double)(x*2.5)); } /** * Square the value x * *

* @param x value to be squared * @return value of the square */ public double square(double x){ return (x*x); } /** * Find the value of the quadratic *

* @param x,a,b,c values to be used in quadratic * @return value of the equation with given values */ public double quadratic(double x, int a, int b, int c){ //no typecasting needed, the equation is promoted //to double because x is a double return (a*(x*x) + b*x + c); } /** * Solve the Quadratic Equation with given values *

* @param a,b,c values to be used in quadratic equation * @return value of the quadratic */ public double solveQuadr(double a, double b, double c){ return (-b + Math.sqrt((b*b) - (4*a*c)))/(2*a); } ////////////////////////////////////////////////////////// /** * Debugging main for class P0Phase3. * This method will rigorously test my code. * *

* @param args IGNORED */ public static void main(String[] args) { //Create variable to test out class P0Phase3 tester = new P0Phase3(); //test methods System.out.println(tester.roundOff(5.454)); System.out.println(tester.divide(10,3)); System.out.println(tester.twoANDAHalfTimes(5)); System.out.println(tester.square(2)); System.out.println(tester.quadratic(2,2,3,4)); System.out.println(tester.solveQuadr(1,2,1)); }// end of main(String[] args) }// end of class P0Phase3