CSC 15 Written Homework Due Monday 9/22 Homework: 1. Given an object "myaccount" of class "bankaccount", show how to invoke (call) the following methods on the object. Assume the bankaccount class has the following interface: void setbalance(double balance); // sets current balance of account void withdraw(double amount); // substract amount from balance double inquiry(); // returns current balance double interest(); // returns the interest rate Note that I'm not asking you to define these methods, just understand how to call them. Write statements that demonstrate how each method should be called. For the methods that return values, you should declare variables and assign to those variables the values returned by the methods. 2. Identify the following as either statements, expressions, or neither (ill-formed). If it's an expression, determine its type. NOTE: I've deliberately removed the ";" from statements - otherwise they'll be too obvious! a. 9 * "5" b. 9/4 c. int x d. int 9 e. "int 9" f. 1 == x g. x = 1 h. '9 * 5' i. "abc" + "d" j. 9.0/4.0 k. System.out.println(9) 3. Write a sequence of statements that: a. Declare x and y to be integer variables b. Declares z to be a char. c. Assign 5 to x d. Assign x*2 to y e. Assign the second, lower-case letter of the alphabet to z. f. increment the value of x so it's one plus its original value (will this also effect y?) 4. Write expressions to: a. compute the circumference of a circle with radius 2.5 (circumference is twice the radius times 3.14). b. determine if x+1 is equal to the same value as y+2 5. Assume x and y are integer variables a. Write an if-else statement that determines if x and y are the same, and if they are the same print "they're the same", otherwise print "they're not the same". b. Write an if-else statement that determines if x is greater than y. If it is, assign to y the value of x, otherwise, assign x the value of y. In other words, after the if-else statement, x and y should both hold the larger of their original values. 6. Determine the output of the following program: int x y; x = 2; y = 4; x = y*x; y = x-1; if (x