This document provides instructions for a midterm exam for a computer science course. It consists of 2 questions worth a total of 24 marks over 50 minutes. Question 1 [10 points] asks students to draw a flowchart for a program that takes in an hour value and outputs the corresponding time of day based on a provided table. Question 2 [14 points] provides the code for a Java program and asks students to write out the output. The instructions emphasize writing initials and details in the proper locations, answering all questions, and not asking questions during the exam.
This document provides instructions for a midterm exam for a computer science course. It consists of 2 questions worth a total of 24 marks over 50 minutes. Question 1 [10 points] asks students to draw a flowchart for a program that takes in an hour value and outputs the corresponding time of day based on a provided table. Question 2 [14 points] provides the code for a Java program and asks students to write out the output. The instructions emphasize writing initials and details in the proper locations, answering all questions, and not asking questions during the exam.
This document provides instructions for a midterm exam for a computer science course. It consists of 2 questions worth a total of 24 marks over 50 minutes. Question 1 [10 points] asks students to draw a flowchart for a program that takes in an hour value and outputs the corresponding time of day based on a provided table. Question 2 [14 points] provides the code for a Java program and asks students to write out the output. The instructions emphasize writing initials and details in the proper locations, answering all questions, and not asking questions during the exam.
No. of Pages 2 No. of Questions 2 Total Marks 24 Time: 50 minutes
Department of Computer Science and Engineering
MIDTERM EXAMINATION Fall 2018 CSE 110: Programming Language I CSE 161: Computer Programming
Write intial (AAR/AKO/AMH/DSH/FSH/JNM/MSI/MSN/NSM/SBI/SHA) of theory
teacher and section on top of the answer script Answer all questions. Use back part of the the answer script for rough work. Answer Question 1 at the beginning part of answer script. Write answer of Question 2 on the question paper. Figure in bracket [] next to each question indicates marks for that question. At the end of exam, put question paper inside answer script and return both. Understanding the question is part of the exam, please do not ask questions. No washroom breaks.
Section: ______ ID: ______________________
Name in CAPITAL: _____________________________________________________
Names/initials of Lab Teachers __________________________________________
Lab Room Number _______________ Lab Day and Time___________________
Question 1 [10 Points]
[Answer on the answer-script] Draw the flowchart of a program that asks the user for hour as input and prints a message, which time of the day it is, based on the following table. For example, if user gives 8, print “early”, if user types, 12, output is “mid-day”etc.
Input Validation: Valid/correct hours are between 0 to 23 (based on 24 hour
clock). If input falls outside this range, print “wrong input”. For example, if user gives 24 or negative numbers, print “wrong input”. Out of Range Values: For valid hours not mentioned in the table, print “unknown”. e.g. if user gives 18, print “unknown”.
Hour Message Hour Message
(input) (output) (input) (output) 6 early 12 mid-day 7 early 13 mid-day 8 early 14 mid-day 9 early 15 late 10 early 16 late 11 early 17 late
Page 1 of 2, Set B, CSE110
Question 2 [14 Points] [answer on question paper] 1. public class Q2B { 2. public static void main(String[] args) { 3. int x = 1, y = 0, sum = 0; 4. while (x < 10) { 5. y = 40; 6. while (y > 22) { 7. if ((sum > 40) || (sum < 100)) { 8. sum += x * 2; 9. } 10. if ((sum > 20) || (sum < 60)) { 11. sum += x * 3; 12. } else { 13. sum += 23; 14. } 15. System.out.println(sum+x); 16. y -= 10; 17. } 18. x += 2; 19. } 20. int a=sum++,b=2,c=4000; 21. int d=a+=b+=c+=50; 22. System.out.println(a); 23. System.out.println(b); 24. System.out.println(c); 25. System.out.println(d); 26. } 27. } Show output of the above program: [Answer on the question paper. There are NO errors / mistakes in this question. The question is correct. ]