Intro -- Method Assignment with CodingBat

Intro – Method Practice (with CodingBat in Java)
1.
partly on-line
ONLINE: The beginning of the Method Practice assignment can be found on the following
web site: www.codingbat.com. <There is a minor IP problem. If it shows an account other
than your own, simply hit <F5> to refresh
properly.> Go to the site and use the menu at the
top to do the following:
a. Select create account, and give yourself a
password.
b. Select prefs, and add your name (# Last,
First) with # as your class period. Add my
e-mail address under Teacher Share:
[email protected].
c. Scroll down the page to the section entitled
Warmup1.
You must complete at least ___4____ Java
assignments under Warmup1 and ____3____
assignments under Logic1.
You will probably not know how to do the
problems associated with Strings, so feel free to
skip them.
[9 points]
OFFLINE: Add the following methods and method calls to the lastname_methodPractice
menu that we started in class. All screen output for your new methods must be in the main
method.
1. public static int rectPerimeter(int length, int width) – Write an int method
that is passed the length and width of a rectangle (both integers) and returns the
perimeter of the rectangle. (You should read in the length and width in the main
method.) [2 points]
2. public static int toThePower(int base, int power) -- Write an int method that
receives a base (an integer) and a power (a nonnegative integer). Without using any
built in Math methods (like Math.pow()), calculate and return the base raised to the
power: basepower. (Remember to read in the parameter values in the main method.)
[ 6 points]
3. public static boolean isPrime(int num) – Write a boolean method that is passed
just one integer greater than 1. The method should return a true if the parameter is a
prime number and false otherwise. Make sure the display to the screen in the main()
method is attractive – the display should NOT include the words true or false. HINT:
This is SIMILAR to your GCD assignment. [7 points]
4. BONUS
#1 – Write a method that calculates the square root of a non-negative integer to
the nearest 4 decimal places without using Math.sqrt() or Math.pow() or any
other Math method (except for Math.abs() ).
#2 – Digits and Nim (in my OUT box)
D:\81913151.doc