akosiraff

Download CSIS 120 Fall 2016 Exam02 Answer

Dec 5th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1.  
  2. Download: https://solutionzip.com/downloads/csis-120-fall-2016-exam02/
  3. General Exam Instructions
  4. 1) Date:
  5. 2) Coverage: 4 & 5
  6. 3) The exam is closed-book closed-notes. You should only have your pen or pencil on the table. All electronic devices including calculators, mobile phones, cameras, PDAs, MP3 players, computers, etc., are NOT permitted in the exam.
  7. 4) Style: written, in class
  8. 5) Duration: 90 minutes
  9. 6) Number of Qs: 8, Number of pages: 8.
  10. 7) % of overall grade: 20%
  11. 8) Make up: ONLY if you present a documented evidence
  12. 9) Blue/Black ink, pencil all are fine, do NOT write in red.
  13. For instructor use only:
  14. Question No. Course Outcome(s) Student Outcome(s) Performance Indicator(s) Mark Awarded Grade
  15. Q1 4 a a1 10
  16. Q2 5 b b1 10
  17. Q3 4 i i1 10
  18. Q4 4 a a3 10
  19. Q5 4 a a1 10
  20. Q6 4 i i1 10
  21. Q7 5 a a3 10
  22. Q8 5 b b1 10
  23. Final Mark: /100
  24. [01] Write a code fragment that accomplishes the following:
  25. 1) Asks the user to enter student emails one name at a time.
  26. 2) If an email does NOT contain ‘@’ it prints the student sequence number and the word “invalid”.
  27. 3) It stops if the user enters “end”.
  28. 4) Prints total number of students with invalid emails.
  29. [02] Implement question [01] as a method that does all stated steps, accepts no parameters and returns number of invalid emails.
  30. [03] Convert the following for-loop into a while-loop and write its output:
  31. double sum = 0;
  32. for(int k=16; k > 0; k /= 2){
  33. sum += k;
  34. sop(k);
  35. }
  36. sop(sum);
  37. double sum = 0;
  38. int k=16;
  39. while( k > 0){
  40. sum+=k;
  41. Sop(k)
  42. k/=2
  43. }
  44. [04] Find and fix all errors in the following code fragment:
  45. The code is supposed to read number of student first names and print the first and last letters of each name. The code quits when the user enters “done”.
  46. String name = “”;
  47. Scanner in = new Scanner(System.in);
  48. while( name != “quit” ){
  49. sop(“enter next name = ” );
  50. in.nextInt() = name; // ERR
  51. name = in.nextInt();
  52. sopl(name(0) + “:” + name(10));
  53. sopl(name.chaAt(0) + “:” + name.chaAt( name.length()-1) )
  54. }
  55. [05] Convert question [03] to a do-loop.
  56. double sum = 0;
  57. int k=16;
  58. do{
  59. sum+=k;
  60. Sop(k)
  61. k/=2
  62. } while( k > 0);
  63. [06] Write a code fragment that does the following:
  64. 1) Calculates multiplication table of the size (10 x 10)
  65. 2) Prints the generated table in (1) above, each row in a separate line
  66. 3) Finds and prints the average of the entire table.
  67. [07] Based on question [06], Write a method that satisfies the following:
  68. 1) Returns a double type
  69. 2) Accepts two parameters as r: number of rows, c: number of columns
  70. 3) Calculates multiplication table of the size specified in (2) above
  71. 4) Prints the generated table in (3) above, each row in a separate line
  72. 5) Finds and returns the average of the entire table.
  73. [08] Write the output of the following code: 10 2 1 2
  74. public static void main(String[] args) {
  75. fun2(10);
  76. fun2(20);
  77. sop(fun1(10));
  78. sop(fun1(20));
  79. }
  80. public static int fun1(int x) {
  81. for (int i = 0; i < 3; ++i) { x /= 2; } return x; } public static void fun2(int x) { if (x > 10) {
  82. sop(fun1(x));
  83. } else {
  84. sop(x);
  85. }
  86. }
  87.  
  88. Download: https://solutionzip.com/downloads/csis-120-fall-2016-exam02/
Add Comment
Please, Sign In to add comment