WhatsApp-00963951432013 Admin
عدد المساهمات : 2429 نقاط : 302124 السٌّمعَة : 4 تاريخ التسجيل : 20/09/2008 العمر : 54 الموقع : www.aoua.123.st
| موضوع: 1 Faculty of Computer Studies Information Technology and Computing Program M105 Tutor-Marked Assignment Course Code: M105 Semester: Fall 2015-2016 Course Title: Introduction to Programming with Java Credit Hours: 3 Hours Cut-Off Da الأربعاء نوفمبر 11, 2015 3:22 am | |
| 1 Faculty of Computer Studies Information Technology and Computing Program M105 Tutor-Marked Assignment Course Code: M105 Semester: Fall 2015-2016 Course Title: Introduction to Programming with Java Credit Hours: 3 Hours Cut-Off Date: Sunday, December 13, 2015 Total Marks: 80 Contents Preface…………………………………………………………………………………………… 1 Instructions for submitting TMA……………………………………………………………….. 1 Question One…………….……………………………………………………………………… 2 Question Two…………………….……………………………………………………………… 2 Question Three…….…………….……………………………………………………………… 3 Question Four………..…………..……………………………………………………………… 3 This TMA covers chapters 1, 2, 4 and 5 of the text book. Instructions for submitting TMA 1. Create a new project in NetBeans. Name it: StudentName_StudentID (e.g. AhmadOmar_099999) 2. Create all the required classes in TMA inside this project. Name each class according to the question No. in addition to your ID (e.g. Q2_StudentID) 3. You will find a solution template (document file) on LMS with the following name: M105-TMA-2015-2016-Fall-Branch-StudentID-FirstNameLastName You should write your answers inside this document, but you need to: a) Sign the “Declaration of No Plagiarism” electronically (it is enough to put your name and ID). b) Modify the following information in the file name: Branch, StudentID and FirstNameLastName Example: "Ahmad Omar" is in Kuwait Branch and his ID is 099999. He should change the file name to be: M105-TMA-2015-2016-Fall-KWT-099999- AhmadOmar 4. Copy and paste the code of all the classes + the required snapshots inside the above document file. 5. Create a compressed file including the folder of your project. 6. Name the compressed file as the document file. 7. Submit two separated files: the compressed file + the document file (without compression). 2 Important Notes: 1) You should solve TMA individually. There are no groups in TMA. 2) When writing your programs, you should follow good programming style that helps readability. This includes: • Using short comment at the beginning stating the purpose of each program. • Selecting meaningful names for identifiers. • Using spacing and indentations to help make the structure of your program clear. You could lose up to 3 marks if you did not do that. Question One: [10 marks] a. Write a Java class (program) that reads from the user a real number represents the length of the hypotenuse of an isosceles right triangle. Then calculates and prints the area of this triangle (rounded to 2 decimal places). [9 marks] Hint: You can search the internet to discover how to calculate the area of an isosceles right triangle when you only know the length of its hypotenuse. b. Give the exact output of your program. Provide a snapshot representing the exact output of any value from your choice. [1 mark] Question Two: [24 marks] a. For any quadratic equation: , there are zero, one or two real solutions. Write a Java application that reads from the user 3 integers represent the values of the coefficients of a quadratic equation (a, b and c). Then computes and prints how many real solutions for the given equation. In addition, if the user enters 0 as the value of a, a suitable error message should be displayed and nothing should be computed. [20 marks] Hints: It is not required to compute the real solutions. Just compute number of them. You can search the internet to discover when a quadratic equation has zero, one or two real solutions. b. Give the exact output of your application. Give 4 snapshots representing the exact output of 4 different cases (i.e., when the number of real solutions is 0, 1, 2 and when the user enters 0 as the value of a). [4 marks] 3 Question Three: [21 marks] a. Assume that a tutor created a 5-mark quiz for his students and he wants to know the mode of students' scores in the quiz. Write a Java program that reads from the user 6 lines of input. Each line includes 2 integers: a score and number of students who got this score. The program should compute and print the mode of students' scores (You can assume that there is always a unique answer) [19 marks] b. Give the exact output of your program. Provide a snapshot representing the exact output of any values from your choice. [2 marks] Hints: You can search the internet to discover how to compute the mode. The input and output of your program should be exactly as in the sample below Sample Input and Output: Please, insert the scores and the frequency of each score: 0 1 1 0 (This line means that no student got 1 out of 5) 2 6 3 9 4 7 (This line means that 7 students got 4 out of 5) 5 4 The mode of students' scores is 3 Question Four: [25 marks] a. Write a Java program that read your first name and the first names of your friends. Then the program should compute and prints the percentage of your friends whose first names start with the same letter as your first name (rounded to 2 decimal places). Enter the word "stop" to stop the program. [24 marks] b. Give the exact output of your program. Provide a snapshot representing the exact output of any values from your choice. [1 marks] Hint: The input and output of your program should be exactly as in the sample below Sample Input and Output: Please, insert your first name: Ahmad Please, insert the first names of your friends (enter "stop" to stop your program): Hisham Ali Nader stop 33.33% of your friends their first names start with the same letter as your first name Explanation: There are 3 friends, 1 of them his first name starts with the same letter as your first name. 1 out of 3 represents 33.33% of your friends ( ). End of Assessment Input from the user You should write your first name here Input from the user | |
|