Computer Science Canada BlueJ Noob!!! Need some help writing some codes |
Author: | tannerbro [ Mon Oct 10, 2011 7:28 pm ] |
Post subject: | BlueJ Noob!!! Need some help writing some codes |
Ok so this was a lab in class that I couldnt quite grasp.....they want me to create a public boolean for a FancyInt Object being a positive number....Everything I completley made from scratch and the only other parameters are the get value, set value, FancyInt, initialValue, and then it asks a few more questions where I get stuck at so here it is..... c. A feature that returns whether or not a FancyInt is positive. The class should implement this feature via a method with the following skeleton: public boolean isPositive () { boolean result; result = true; // dummy result initialization; ??? FIX ME return true; } // isPositive d. A feature that returns whether or not this FancyInt object is even. Please use a method signature similar to the one used for isPositive. e. A feature that views the value of this FancyInt object as a temperature in degrees Celsius and returns its Fahrenheit equivalent. The class should implement this feature via a method with the following signature Also they want me to create a method so I can turn a value into Celsius but have it returned as Fharenheight...and vice versa.... any suggestions would be appreciated. |
Author: | Tony [ Mon Oct 10, 2011 9:21 pm ] |
Post subject: | RE:BlueJ Noob!!! Need some help writing some codes |
so given some value (e.g. 4), how do you know if it's positive or not? |
Author: | huskiesgoaler34 [ Thu Oct 13, 2011 9:30 am ] |
Post subject: | Re: BlueJ Noob!!! Need some help writing some codes |
C x 9/5 + 32 = F (F - 32) x 5/9 = C Just use these calculations inside the method that you are using for the conversions. For the first question (determine whether fancyInt is positive), use a command that checks to see if the number is greater than 0 or less than 0. |