Quizzes

Ace your homework & exams now with Quizwiz!

Given that a method receives three parameters a, b, c, of type double, write some code, to be included as part of the method, that checks to see if the value of a is 0; if it is, the code prints the message "no solution for a=0" and returns from the method.

if (-0.000001 < a && a < 0.0000001) { System.out.println("no solution for a = 0)" ; return; }

Given the int variables x, y, and z, write a fragment of code that assigns the smallest of x, y, and z to another int variable min. Assume that all the variables have already been declared and that x, y, and z have been assigned values.

min = x; if (y < min) min = y; if (z< min) min = z;

Write the definition of a method add, which receives two int parameters and returns their sum.

public static int add (int a, int b) { return a + b; }

Write the definition of a method twice, which receives an int parameter and returns an int that is twice the value of the parameter.

public static int twice (int x) { return * x; }


Related study sets

Science Convection and the Mantle

View Set

MKT 3311 Principles of Marketing chapter 15

View Set

bio exam 3 test bank pt 1 questions(chp 17)

View Set