text: Full file at
  Name:_______________________ Covers Chapters 1-3 50 mins
  CSCI 1301 Introduction to Programming Armstrong Atlantic State University Instructor: Y. Daniel Liang
  I pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class. Signed by ___________________ Date ___________________ Part I. (10 pts) Show the printout of the following code: (write the printout next to each println statement if the println statement is executed in the program). public class Test { public static void main(String[] args) { System.out.println((int)(Math.random())); System.out.println(Math.pow(2, 3)); System.out.println(34 % 7); System.out.println(3 + 4 * 2 > 2 * 9); int number = 4; if (number % 3 == 0) System.out.println(3 * number); System.out.println(4 * number); int x = 943; System.out.println(x / 100); System.out.println(x % 100); System.out.println(x + " is " + ((x % 2 == 0) ? "even" : "odd")); int y = -1; y++; System.out.println(y); } } Part II:
  Write a program that prompts the user to enter the exchange rate from currency US dollars to Chinese RMB. Prompt the user to enter 0 to convert from US dollars to Chinese RMB and 1 vice versa. Prompt the user to enter the 1. (10 pts)
  1
  Full file at
  amount in US dollars or Chinese RMB to convert it to Chinese RMB or US dollars, respectively. Here are the sample runs: <Output> Enter the exchange rate from dollars to RMB: 6.81 Enter 0 to convert dollars to RMB and 1 vice versa: 0 Enter the dollar amount: 100 $100.0 is 681.0 Yuan <End Output> <Output> Enter the exchange rate from dollars to RMB: 6.81 Enter 0 to convert dollars to RMB and 1 vice versa: 1 Enter the RMB amount: 10000 10000.0 Yuan is $1468.43
  <End Output> <Output> Enter the exchange rate from dollars to RMB: 6.81 Enter 0 to convert dollars to RMB and 1 vice versa: 5 Incorrect input <End Output>
  2
  Full file at
  2. >
  3
  Full file at
  Name:_______________________ Part III: Multiple Choice Questions: (1 pts each) (Please circle your answers on paper first. After you finish the test, enter your choices online to LiveLab. Log in and click Take Instructor Assigned Quiz. Choose Quiz1. You have 5 minutes to enter and submit the answers.) 1. The expression (int)(76.0252175 * 100) / 100 evaluates to _________. a. b. c. d. # 2.
  76 76.0252175 76.03 76.02 What is y after the following switch statement? int x = 0; int y = 0; switch (x + 1) { case 0: y = 0; case 1: y = 1; default: y = -1 }
  a. b. c. d.
  2 1 0 -1
  # 3. Assume x is 0. What is the output of the following statement? if (x > 0) System.out.print("x is greater than 0"); else if (x < 0) System.out.print("x is less than 0"); else System.out.print("x equals 0"); a. b. c. d.
  x is less than 0 x is greater than 0 x equals 0 None
  # 4
  Full file at
  4.
  Analyze the following code:
  Code 1: boolean even; if (number % 2 == 0) even = true; else even = false; Code 2: boolean even = (number % 2 == 0); a. b. c. d.
  Code 2 has syntax errors. Code 1 has syntax errors. Both Code 1 and Code 2 have syntax errors. Both Code 1 and Code 2 are correct, but Code 2 is better.
  # 5. What is the printout of the following switch statement? char ch = 'a'; switch (ch) { case 'a': case 'A': System.out.print(ch); break; case 'b': case 'B': System.out.print(ch); break; case 'c': case 'C': System.out.print(ch); break; case 'd': case 'D': System.out.print(ch); } a. b. c. d. e.
  ab a aa abc abcd
  5
  Full file at
  # 6.
  What is x after evaluating
  x = (2 > 3) ? 2 : 3; a. b. c. d.
  5 2 3 4
  # 7.
  Analyze the following code. int x = 0; if (x > 0); { System.out.println("x"); }
  a. b. c. d.
  The value of variable x is always printed. The symbol x is always printed twice. The symbol x is always printed. Nothing is printed because x > 0 is false.
  # 8. To declare a constant MAX_LENGTH inside a method with value 99.98, you write a. b. c. d.
  final double MAX_LENGTH = 99.98; double MAX_LENGTH = 99.98; final MAX_LENGTH = 99.98; final float MAX_LENGTH = 99.98;
  # 9. Which of the following is a constant, according to Java naming conventions? a. b. c. d. # 10.
  read MAX_VALUE ReadInt Test
  What is y after the following switch statement is executed?
  x = 3; switch (x + 3) case 6: y case 7: y default: y
  { = 0; = 1; += 1;
  6
  Full file at
  } a. b. c. d. e.
  1 4 3 2 0
  # 11. Which of the following code displays the area of a circle if the radius is positive. a. b. c. d.
  if if if if
  (radius (radius (radius (radius
  <= 0) System.out.println(radius * radius * 3.14159); != 0) System.out.println(radius * radius * 3.14159); >= 0) System.out.println(radius * radius * 3.14159); > 0) System.out.println(radius * radius * 3.14159);
  Please double check your answer before clicking the Submit button. Whatever submitted to LiveLab is FINAL and counted for your grade. Have you submitted your answer to LiveLib? ______________ What is your score? ______________
  7