CSC 108 Midterm - Spring 1998 - Friday Section ============================================== 1. [10 marks] Below is a Java program segment that begins with some variable declarations and ends with a sequence of assignment statements. Each assignment statement attempts to give a new value to a variable. To the right of each assignment statement, write the value assignmed to the variable, and do not include a decimal point otherwise. In addition, put single quotes around characters, put double quotes around strings, and clearly indicate whether or not a blank is included in the string. If the assignment statement would fail, write the word "Error" and briefly explain what the error is to the right of the statement. boolean b; char c; float f; int i; String s; i = 2 + 3 * 5; i = 7 % 3 + 1; i = 4 / 2.0; i = 5 * 2; f = 2 * 3; s = "Hi" + "There"; c = s.charAt (1); b = s.startsWith ('H'); b = 10 > 2 + 3; i = (int) 6.75; b = i == 6 || 7; 2. [10 marks: 8 marks for part (a), 2 marks for part (b)] (a) The Fly-By-Night Finance Company needs a program to keep track of its customers. Write a Java class called Customer with the instance variables name (String), number (long) and balance (double). Include a constructor in the class to initialize these instance variables when you instantiate an object of this class. Also include a print method in the class to print the name, number, and balance of the object. (b) Write a brief Java program segment to instantiate an object called new_customer of the Customer class and initialize its instance variables name to "John Doe," number to 94523 and balance to 99.67. Then call the print method associated with the object to print the information associated with the object. 3. [10 marks] Write a Java String method called reverse that accepts on String argument word and returns a String that consists of the letters of the argument word in reverse order. For example, if the argument word is the String "computer", then reverse should return the String "retupmoc". Do NOT use the StringBuffer class method reverse.