Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 BlueJ Noob!!! Need some help writing some codes
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
tannerbro




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: 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?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
huskiesgoaler34




PostPosted: 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.
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: