This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I need write a method, called calculateFunction, that calculates the value of y for various values of x. The declaration of this method is below:
public int calculateFunction(int x); The calculateFunction method calculates the function y = x + x2 + 2x. To calculate the values of this expression, you can use:
x2 = x * x 2x = Math.pow(2,x)
Note that because calculateFunction works in terms of int, and Math.pow returns a double, you must cast the value returned to an int, or Java will give you a compiler error about loss of precision.
Once the function has been calculated, print out the relative size of the result by calling the method printStars used in module 3 of the course modules. Calculate this function and print out its relative size for values from 1 to 10. Note that to make the number of stars reasonable, you should print out 1 star for each value of 10 returned (for example, if 62 is returned, you should print out 6 stars). You can do so by dividing by 10, noting that the value will be truncated to the next lowest int value.
Im very new and can anybody help be how to begin this problem..just the basic idea? plzzz...
You also need to comply with the JavaRanch JavaRanch policy on display names before most folks will feel inclined to help you. You can change your name to a suitable firstname lastname combination by visiting here.